Click here to Skip to main content
15,914,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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;
        }
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900