I have this issue with a SQL statement that uses strings as part of the Where clause. I search this database for similar situations, found some responses and tried them but still could not get my code to work.
I'm using VB
6.0 to retrieve some rows from an MS Access table.
Here's my code:
sSql = "Select * From SCR_Log Where BaseSCRID = " & lBaseSCRID
sSql = sSql & " And EmailSubject = '" & constantAValue
sSql = sSql & "' And UsedFlag = " & constantNo
oRS.Open sSql, oConn, adOpenDynamic, adLockOptimistic
Here's the value of SQL after setting it as above in VB
"Select * From SCR_Log Where BaseSCRID = 45000 And EmailSubject = 'SCR2K2 Email Notification Change' And UsedFlag = No"
BaseSCRID is a Number, EmailSubject is Text and UsedFlag is Yes/No.
I also tried using double quotes but that didn't work either.
Here's the value of sSql with double quotes that also does not work:
"Select * From SCR_Log Where BaseSCRID = 45000 And EmailSubject = "SCR2K2 Email Notification Change" And UsedFlag = No"
Another thing I tried to use was chr(34) but still no success.
Any suggestions would be greatly appreciated.