|
-
Jan 20th, 2000, 01:25 AM
#1
Thread Starter
Frenzied Member
Yes, because, in a similar way to Pascal, two single quotes in a row is interpreted as one single quote contained within a string.
I just thought maybe that could do with explaining.
-
Jan 20th, 2000, 03:16 AM
#2
Lively Member
That worked. Thanks for the help.
-
Jan 20th, 2000, 12:04 PM
#3
Lively Member
Does anyone have a work around for handling strings containing apostrophies that are being passed into a SQL statement?
Example. I have form with a textbox for Last Name, First Name and Phone Number. If the lastname box contains something like O'Hara I get a syntax error when I try to run
"INSERT INTO contacts (lastname, firstname, phone) VALUES ('" & txtLastname.text & "', '" & txtFirstname.text & "', '" & txtPhone.text & "'). The apostrophy in O'Hara is being confused with the tick in my SQL statement. I am using an Access database.
Any help would be appreciated.
-
Jan 20th, 2000, 12:24 PM
#4
Guru
you can use the VB6 REPLACE function to find those single quotes and convert them to double single quotes...
Code:
dim strSQL as string
strSQL = "Select * from Customers where CustomerID = '" & replace(text1.text, "'", "''") & "'"
HTH
Tom
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|