在存储过程的帮助下传递参数? [英] passing parameters with help of stored procedure??

查看:105
本文介绍了在存储过程的帮助下传递参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面创建了一个函数给定并传递了一个参数.我使用了一个简单的查询来访问数据库..有什么方法可以通过带参数的存储过程来代替简单查询,因为存储过程是更好的方法

i created a function give below and passed a parameter to it.i used a simple query to access the database..is there any way to do it with a stored procedure with parameters instead of a simple query as stored procedure is a better method

public bool isoffsetexist(int offset)
    {
        conn.Open();

        SqlCommand cmd = new SqlCommand("select * from tb_offset where offset= " + offset + "", conn);

        SqlDataReader dr = cmd.ExecuteReader();

        int i = 0;
        while (dr.Read())
        {
            i++;
        }
        if (i == 1)
        {
            conn.Close();
            return true;
        }
        else
        {
            conn.Close();
            return false;
        }

推荐答案

您可以从此处开始 http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx [ ^ ]
You can start from here http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx[^]


这篇关于在存储过程的帮助下传递参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆