Click here to Skip to main content
15,910,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
cmd.CommandText = " update studet set name='"&TextBox1.Text "','"&textbox2.Text "','"&TextBox3.Text '",total='"&TextBox4.Text& '" where id='"&Textbox1.Text'" "
Posted

You may be missing a few &'s. Try
cmd.CommandText = " update studet set name='"&TextBox1.Text&"','"&textbox2.Text&"','"&TextBox3.Text &'",total='"&TextBox4.Text& '" where id='"&Textbox1.Text'" "
 
Share this answer
 
Comments
Member 1097736 15-Feb-15 12:09pm    
still couldn't clear the error
Your approach is wrong from the very beginning. You should never create a query by concatenation of string taken from your UI. Instead, you need to use parametrized statements. Please see: http://msdn.microsoft.com/en-us/library/ff648339.aspx[^].

If you do it your way, you make your application totally vulnerable to a well-known exploit: SQL Injection. The user can write anything in the UI, including some SQL fragment. Are you getting the idea? This is how: http://xkcd.com/327[^].

Please see my past answers:
EROR IN UPATE in com.ExecuteNonQuery();[^],
hi name is not displaying in name?[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900