i have created this function with a parameter offset and i want to access the database using stored procedure but the code and stored procedure i have written below is not working...what is the right way to do it??
my stored procedure "sp_offset1 " is
Code:
public bool isoffsetexist(int offset)
{
conn.Open();
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;
}
}
Code:
CREATE PROCEDURE [dbo].[sp_offset1] @offset numeric, @appname varchar(20), @os varchar(20) AS select * from tb_offset where @offset=" + offset + "