My sql table structure is this
ID DataName
1 Lipsum lorem
3 lipsum's lorem
My inline query in asp.net is that
select * from table where DataName like 'lipsum's lorem'
It gives the following errors:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 's'.
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string ''.
I don’t want to create a stored procedure to prevent this, I want a solution to this using inline queries.
Your query should look like…
As you need to escape the
' to 'to get it to work.For more details check out this link: http://blog.sqlauthority.com/2008/02/17/sql-server-how-to-escape-single-quotes-fix-error-105-unclosed-quotation-mark-after-the-character-string/
If you use
Command Parameters, check this link out: