ssswamii

ssswamii

  • NA
  • 180
  • 0

SQL command problem

Sep 29 2003 11:43 AM
Hey all I'm having trouble with SQL commands that contain single quote characters. It seems that single quote characters in a SQL command confuse the darn thing. Example: --------------------------------------- // the text I want to store in the SQL database string text = "Here is a single line quote ' there it was"; string sqlCommand = string.Format("Update myDataTable set Text = '{0}', where (ID = 3456781)", text); --------------------------------------- When I .ExecuteNonQuery(), it will throw an exception telling my I've got bad sql command syntax due to the single quote character in text. It works fine if I take the single quote character out. Now I'm very new to SQL, so I'm probably missing something simple. How do I get around this simple syntax issue? Mr. Chornberger, I'm looking your way. :)

Answers (5)