In the database the database to operate "near grammatical mistakes." String ')' quotes after incomplete "error

See this problem, first check whether the SQL statement is missing 'if there is a single quote (data number ,, how SQL statements are no errors, you get a check in the ""), double quotes "" "(" ""), etc.

How the data obtained with a single and double quotation marks, the connection method to use SQL to manipulate data. SQL connection method is the symbol "@."

E.g

 1 string sql = "update Users set " + "UserRoleId=@UserRoleId," + "UserStateId=@UserStateId," + "LoginId=@LoginId," + "LoginPwd=@LoginPwd," + "Name=@Name," + "Address=@Address," + "Phone=@Phone," + "Mail=@Mail " +" where Id=@Id";
             SqlParameter [] to =2new SqlParameter[]
 3             {
 4                 new SqlParameter("@Id",us.Id),
 5                 new SqlParameter("@LoginId",us.LoginId),
 6                 new SqlParameter("@LoginPwd",us.LoginPwd),
 7                 new SqlParameter("@Name",us.Name),
 8                 new SqlParameter("@Address",us.Address),
 9                 new SqlParameter("@Phone",us.Phone),
10                 new SqlParameter("@Mail",us.Mail),
11                 new SqlParameter("@UserStateId",us.UserStates.Id), //FK
12                 new SqlParameter("@UserRoleId",us.UserRoles.Id) //FK
13              };
14             DBHelper.ExecuteCommand(sql, para);

It can be.

 

Guess you like

Origin www.cnblogs.com/my1227/p/11692705.html