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.
Loading
Kunal VaishyaPosted May 28, 2012, 2:50 AM
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
Sam HobbsPosted Sep 25, 2010, 12:29 AM
Bryian TanPosted Sep 23, 2010, 11:51 PM
Are you getting any errors? Have you tested the update_pro SP individually?