adding strings with a quote in SQL

  • Thread starter Thread starter Thierry
  • Start date Start date
T

Thierry

Hi,



I've got a problem with adding strings with a quote in SQL.



Dim LocationName As String = "for' example"



Dim strQuery As String = "select count(*) as fldNumber "

strQuery += "from " & TableName & " "

strQuery += "where " & FieldName & " like ' " & LocationName & "% '
"



What do I have to do to get LocationName into the query and get this
working?



Thanks,

Thierry
 
Thierry said:
What do I have to do to get LocationName into the query and get this
working?

You have to "escape" the quote. How you do that depends on the database.
Which database are you using?
 
I use SQL-server.
How can I escape the quote.


gabriel said:
You have to "escape" the quote. How you do that depends on the database.
Which database are you using?
 
I may be misunderstanding you question - but I run a function that replaces
' with '' (one apostrophie with 2 apostrophies) and I have not had problems
since. I use SQL server also.

bj daniels
(e-mail address removed)
 
Back
Top