hello!im trying to update from text box to database. it doesnt work.
this is my code on button click, where im wrong?
cmd = new SqlCommand("update_pro", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@id", SqlDbType.NChar).Value = TextBoxid1.Text;
cmd.Parameters.Add("@fname", SqlDbType.NChar).Value = TextBoxfname1.Text;
cmd.Parameters.Add("@lname", SqlDbType.NChar).Value = TextBoxlname.Text;
cmd.Parameters.Add("@id_num", SqlDbType.NChar.Value = TextBoxid2.Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
thank you.
Update data from textBox to DataBase
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Bryian TanRank #396 · 6.3K reputationPosted Sep 23, 2010, 7:51 PM EDT
Are you getting any errors? Have you tested the update_pro SP individually?
Sam HobbsRank #107 · 20.5K reputationPosted Sep 24, 2010, 8:29 PM EDT
Kunal VaishyaRank #990 · 2K reputationPosted May 27, 2012, 10:50 PM EDT
first use NVarchar Instead Of NChar in Coding and Sp Both and use try catch to find which error you are getting
1.
NVarchar
After If got any problem then
make sure in sp any all field require or not if yes then check all text box must have some value
After If still got any problem then
send your SP Code