SqlClient.SqlException: Line 1: Incorrect syntax near '='.

  • Thread starter Thread starter Patrick Olurotimi Ige
  • Start date Start date
P

Patrick Olurotimi Ige

why is this giving me error System.Data.SqlClient.SqlException: Line 1:
Incorrect syntax near '='.??
my code is in c#

strSql = "Update addmessage Set message = '"+null+"' Where ID=" +ID;

strSql = "Update addmessage Set message = '"+message+"' Where ID=" +ID;
 
I think if you want to write null as null and not as String into the DB
it is not correctly quoted!
 
Do as Christian said. Do not make null a string ( don't include within a
single quote)

strSql = "Update addmessage Set message = "+ NULL +" Where ID=" +ID;
 
Thx for the reply....
The thing is 'm changing apps that has been built before..Guess store
procs would save my time
 
Back
Top