1) Why are you setting the value of a column that you know must equal the value already?
UPDATE tbl_update_record SET name=@Name, ... WHERE name=@Name
2) Connections, Commands, and so forth are scarce resources, you should Close and Dispose them when you are finished with them.
A
using
block is the simplest way:
using (cn = new SqlConnection(cs))
{
cn.Open();
using (SqlCommand cmd = new SqlCommand("Sp_Register_Login_Update", cn))
{
cmd.Parameters.AddWithValue("@Name", txtfname.Text);
cmd.Parameters.AddWithValue("@Mobile_No", txtmobileno.Text);
cmd.Parameters.AddWithValue("@Address", txtaddress.Text);
cmd.CommandType = CommandType.StoredProcedure;
int j=cmd.ExecuteNonQuery();
if (j != 0)
{
lblmsg.text("Record Updated Successfully..");
}
}
}
3) If that code isn't working, check your stored procedure, then use the debugger to see exactly what is in
txtfname.Text
and the
name
column of your table.