For procedures with few parameters I use this, thus ensures that all types of data work, if you have Boolean data, integer or datetime work.
protected void btnUpdate_Click(object sender, EventArgs e)
{
bool t = sp_update(txtEmpId.Text,txtEmployeeName.Text,txtEmpAddress.Text,txtMobile.Text);
if (t)
{
lblResult.Text = "Value Updated";
}
else
{
lblResult.Text = "Failed";
}
}
public bool sp_update( string EmpId ,string EmpName,string EmpAdd,string Phone)
{
bool _flag = false;
SqlConnection _conn = new SqlConnection(connstr);
try
{
SqlCommand _cmd = new SqlCommand();
_cmd.Connection = _conn;
_cmd.CommandType = CommandType.Text;
_cmd.CommandText = String.Format(" exec dbo.sp_Update @EmpId ='{0}',@EmpName='{1}',@EmpAdd='{2}',@Phone='{3}'", EmpId ,EmpName,EmpAdd,Phone);
_conn.Open();
_cmd.ExecuteNonQuery();
_conn.Close();
_flag = true;
}
catch (ServiciosSqlNet.SqlNetException ex)
{
throw new Exception(ex.Message, (Exception)ex);
}
catch (Exception ex)
{
throw ex;
}
return _flag;
}