I'm working in Microsoft Visual C# 2008 Express with Sqlite.
I understand that an apostrope (') in my text has problems in a query. My problem is that I thought I could replace it with '. It doesn't seem to be working... Here's a parred down example of my code:
string myString = "I can't believe it!";
cmd.CommandText = "Insert into myTable (myid,mytext) values (1,'" + myString.Replace("'","\'") + "');";
The error I get is:
SQLite error:
near "t": syntax error
I've tried a couple other replacements... like the other slash. And I wrote my string and a replaced version of my string out to the console to make sure it was coming out right.
What stupid error am I making here?
Thanks!
-Adeena
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…