Click to See Complete Forum and Search --> : String Question


Limor Janah
January 16th, 2003, 01:13 AM
Hi

I have a basic question
I am using SQL command/query like
"INSERT INTO table1 (FName) VALUES (' " & sStr & " ' )"
If sStr (the string) contain the char " ' " then I get an error
I understand why it happened but I need a way around it

Thanks
Limor

DdH
January 16th, 2003, 04:27 AM
If a string that has to be insert or update into a database countains any single '
you have to double them to 2 single ' , so the database knows it is a character of the string and not of the whole sql-statement.

Add the following line just before you put the whole sql-statement together.

sStr = sStr.Replace("'", "''")

NV2002
January 16th, 2003, 01:51 PM
Yes the old DoubleQuote Problem