IGBP
01-10-2004, 02:08 PM
Hi everyone ...
I am using this code to get one specific record from an Access 2000 Database using VB6 and an ADODB connection and recordset.
strSql = "Select * From Suppliers where CompanyName = '" & strCoName & "'" '& ";"
That passes a SQL statement to a .BAS module that actually has all the connection code. It works UNLESS the strSQL has a space in it .
ie ...
If the strSQL is company1 it works great ...
However
If the strSQL is company 2 ... it returns no records
I know that you need to use [] around the string containing spaces, but I cannot get it to work in this case because strCoName is a variable.
Any ideas on what to do?
Thanks
Michael
Edit: fixed typo
I am using this code to get one specific record from an Access 2000 Database using VB6 and an ADODB connection and recordset.
strSql = "Select * From Suppliers where CompanyName = '" & strCoName & "'" '& ";"
That passes a SQL statement to a .BAS module that actually has all the connection code. It works UNLESS the strSQL has a space in it .
ie ...
If the strSQL is company1 it works great ...
However
If the strSQL is company 2 ... it returns no records
I know that you need to use [] around the string containing spaces, but I cannot get it to work in this case because strCoName is a variable.
Any ideas on what to do?
Thanks
Michael
Edit: fixed typo