Incorrect Syntax Near 's'. Unclosed Quotation Mark After The Character String ')'
I am kinda noob in programming, and I was wondering what I have done wrong here - can some one help me out? I am making a console app in which it syncs two databases, but when I t
Solution 1:
The data you are inserting probably contains special characters like single quotes. Change to a parameterized query so the values are escaped properly. A good example and explanation is http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html.
[Edit: Added an example. ]
For example, replace the contents of your first function with:
SqlCommand insertNewAreaPath = new SqlCommand(
"INSERT INTO InterationPath (ID, NodePath) VALUES(@ID, @NodePath)",
conDS_ReleaseCriterions);
insertNewAreaPath.Parameters.Add("@ID", dr[0]);
insertNewAreaPath.Parameters.Add("@NodePath", dr[2]);
insertNewAreaPath.ExecuteNonQuery();
Solution 2:
If you have "'" inside of value of string then that type's of error is comming, So remove "'" from string then execute query.
Post a Comment for "Incorrect Syntax Near 's'. Unclosed Quotation Mark After The Character String ')'"