Sqlite Error: Near "s": Syntax Error
me always get this error near 's': syntax error my implementation: litecon.ConnectionString = 'Data Source=' + AppAddress + '\\database\\mynew22.db;Version=3;UTF16Encoding=True'
Solution 1:
When str
has a value containing an apostrophe, this query will not work because the string will be terminated too early:
select*from mey where trans like'%King Solomon's Mines%'
You must use parameters:
cmd = newSQLiteCommand("select * from mey where trans like @pattern", litecon);
cmd.Parameters.AddWithValue("@pattern", "%" + str + "%");
Solution 2:
The problem is usually with apostrophe. You CAN use them but has to be doubled like, as mentioned in another answer,
select * from mey where trans like '%King Solomon's Mines%'
should changed to
select * from mey where trans like '%King Solomon''s Mines%'
.
A quick solution is to do "select * from mey where trans like "+"'%King Solomon's Mines%'".Replace("'","''")
That would succeed in any case.
Solution 3:
The problem was solved!
used these library and The problem was solved... http://www.devart.com/dotconnect/sqlite/download.html
thanks guys
Post a Comment for "Sqlite Error: Near "s": Syntax Error"