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
Code:
public bool isoffsetexist(int offset)
{
conn.Open();
SqlCommand cmd = new SqlCommand("select * from tb_offset where offset= " + offset + "", conn);
/*SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_offset1";*/
SqlDataReader dr = cmd.ExecuteReader();
int i = 0;
while (dr.Read())
{
i++;
}
if (i == 1)
{
conn.Close();
return true;
}
else
{
conn.Close();
return false;
}
Comment