simple solution but for the life of me I cannot figure it out.
-
Here is a SQL string I am execute with an ADO connecion object. objAdoCon.Execute "insert into MEQUERY " _ & "(MESystemListCode, MEQueryName , MESystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, MEStoreProc) " _ & "values " _ & "(" & cboSystem.ItemData(cboSystem.ListIndex) & ", " _ & "'Profile', " _ & "'" & Trim$(txtQuery.Text) & "', " _ & "'" & Trim$(txtSelect.Text) & "', " _ & "'" & Trim$(txtFrom.Text) & "', " _ & "'" & Trim$(txtWhere.Text) & "', '" _ & Trim$(txtOrderBy.Text) & "', '" _ & Trim$(txtStoredProc.Text) & "')" Here is the result of this query.. objADOCon.Execute "insert into MEQUERY (MESystemListCode, MEQueryName , " _ & "SystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, " _ & "MEStoreProc) " _ & "values " _ & "(3, 'Profile', 'Merchant Search', 'merchant', 'merchants', " _ & "'merchant like '%Bob%'', 'merchant', ''):confused: give this error: Error #: -2147217900 Error Desc: Line 1: Incorrect syntax near '%Bob%'. Error Source: Microsoft OLE DB Provider for SQL Server How can I execute this proc with out having the '' in the query... Latter:cool: Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."
-
Here is a SQL string I am execute with an ADO connecion object. objAdoCon.Execute "insert into MEQUERY " _ & "(MESystemListCode, MEQueryName , MESystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, MEStoreProc) " _ & "values " _ & "(" & cboSystem.ItemData(cboSystem.ListIndex) & ", " _ & "'Profile', " _ & "'" & Trim$(txtQuery.Text) & "', " _ & "'" & Trim$(txtSelect.Text) & "', " _ & "'" & Trim$(txtFrom.Text) & "', " _ & "'" & Trim$(txtWhere.Text) & "', '" _ & Trim$(txtOrderBy.Text) & "', '" _ & Trim$(txtStoredProc.Text) & "')" Here is the result of this query.. objADOCon.Execute "insert into MEQUERY (MESystemListCode, MEQueryName , " _ & "SystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, " _ & "MEStoreProc) " _ & "values " _ & "(3, 'Profile', 'Merchant Search', 'merchant', 'merchants', " _ & "'merchant like '%Bob%'', 'merchant', ''):confused: give this error: Error #: -2147217900 Error Desc: Line 1: Incorrect syntax near '%Bob%'. Error Source: Microsoft OLE DB Provider for SQL Server How can I execute this proc with out having the '' in the query... Latter:cool: Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."
'merchant like '%Bob'' needs to look like this: 'merchange like ''%Bob''' Basically you want to check all your textboxes for single quotes and replace any single quotes with two single quotes. You could also try making this a stored procedure and using an ADO command object, it *might* make things easier but I'm not guaranteeing anything. Good luck! Andy Gaskell, MCSD
-
'merchant like '%Bob'' needs to look like this: 'merchange like ''%Bob''' Basically you want to check all your textboxes for single quotes and replace any single quotes with two single quotes. You could also try making this a stored procedure and using an ADO command object, it *might* make things easier but I'm not guaranteeing anything. Good luck! Andy Gaskell, MCSD