adding strings with a quote in SQL

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
 
G

gabriel

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?
 
T

Thierry

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?
 
B

bj daniels

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top