简体   繁体   中英

System Data SqlClient SqlException

I have to execute an updating query :

 using (SqlCommand sqlCmd = new SqlCommand("UPDATE  Test SET Testedpiece = Testedpiece + 1 and Rate = (Testedpiece  * 100) / Totalpiece  WHERE IDSuperlot = @super", connexion))

But i have this error System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'and'.

I don't know why this error appears and how can i fix it

  1. What is the Sql Syntax error?
  2. How can i fix it?

Your sql command starts like this:

UPDATE  Test SET Testedpiece = Testedpiece + 1 and Rate = ...

change it to this:

UPDATE  Test SET Testedpiece = Testedpiece + 1, Rate = ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM