Click here to Skip to main content
14,929,655 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
   
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
Maciej Los 19-Mar-14 16:48pm
   
Who knows? It happens. See my answer ;)
Krunal Rohit 19-Mar-14 16:49pm
   
I mean seriously, sometimes I don't get it.
Even if the answer is accepted by OP, others are still downvoting it.

-KR
Maciej Los 19-Mar-14 16:57pm
   
I'm seriously too. You're not the only one. I'm calling it: the series law.
Try this

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

Please, see my past 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