Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SqlCommand cmd = new SqlCommand(("UPDATE [Students Records]SET "+ textBox2.Text "='" +textBox3.Text"'WHERE [Reg.No]='"+ textBox1.Text "'"), con);


This line of code gives an error:
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.
please answer it??
Posted

C#
SqlCommand cmd = new SqlCommand(("UPDATE [Students Records]SET "+ textBox2.Text "='" +textBox3.Text + "'WHERE [Reg.No]='"+ textBox1.Text +"'"), con);

you forgot to add '+' at the end of the statement.

-KR
 
Share this answer
 
Comments
Member 10564850 19-Feb-14 11:30am    
it didn't work :(
Krunal Rohit 19-Feb-14 11:30am    
now what happened ?
-KR
Member 10564850 19-Feb-14 11:33am    
hogaya thanku
Krunal Rohit 19-Feb-14 21:08pm    
Accept the solution, If you found your answer :)
-KR
Krunal Rohit 19-Mar-14 12:04pm    
Why is is downvoted ??

-KR
Try this

C#
SqlCommand cmd = new SqlCommand("UPDATE [Students Records]SET "+ textBox2.Text +  "='" + textBox3.Text + "'WHERE [Reg.No]='"+ textBox1.Text +  "'", con);
 
Share this answer
 
Solution 1 is good, but you need to get some extra information.

Please, see my past answer[^].
 
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