July 19th, 2000, 03:52 PM
Hi,
My program has a listbox, which lists all the product names. Some of the products names contain one or more single quotes ('). The problem is the following. Please look at the code...
=====================================
Dim db as Database
Dim rs as Recordset
Set db =OpenDatabase(App.Path & "/mydb.mdb")
Set rs= db.OpenRecordset("SELECT * FROM MainTable Where [ItemName]='" _
& lstItems.text & "'" , dbOpenDynaset) 'Where lstItems is the listbox control
========================================
lstItems has the product name of "American's Flag 4'x8'". When I put it into the SQL statement, it returns a Syntex error because the single quotes ('). Is there anyone knows how to solve the problem? In C, I know that I could reformat the string as
Str="American\'s Flag 4\'x8\'"
How can I do the same thing in VB?
Thank You.
My program has a listbox, which lists all the product names. Some of the products names contain one or more single quotes ('). The problem is the following. Please look at the code...
=====================================
Dim db as Database
Dim rs as Recordset
Set db =OpenDatabase(App.Path & "/mydb.mdb")
Set rs= db.OpenRecordset("SELECT * FROM MainTable Where [ItemName]='" _
& lstItems.text & "'" , dbOpenDynaset) 'Where lstItems is the listbox control
========================================
lstItems has the product name of "American's Flag 4'x8'". When I put it into the SQL statement, it returns a Syntex error because the single quotes ('). Is there anyone knows how to solve the problem? In C, I know that I could reformat the string as
Str="American\'s Flag 4\'x8\'"
How can I do the same thing in VB?
Thank You.