English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am running a query thru VB using LIKE command and it should return a value but doesn't. When I run the program in DEBUG mode and grab the SQL query string via COPY and PASTE it into ACCESS the query qorks fine and retruns the record. Why does it not work?
here is a sample of the code:
sqlstring = "SELECT * FROM stone WHERE stone1 LIKE '*" & stone1var & "*' OR stone2 LIKE '*" & stone1var & "*'"

and the copied string is pasting like this:

SELECT * FROM stone WHERE stone1 LIKE '*2-1-222*' OR stone2 LIKE '*2-1-222*'


Can someone help please???

2006-09-01 09:09:25 · 2 answers · asked by solomon d 2 in Computers & Internet Programming & Design

2 answers

In VB, you use % instead of *:

SELECT * FROM stone WHERE
stone1 LIKE '%2-1-222%' OR
stone2 LIKE '%2-1-222%'

The * will really works in ACCESS but not in VB.

Cheers!

2006-09-01 13:22:55 · answer #1 · answered by VBACCESSpert 5 · 1 0

VB script language is very different from SQL script language. They are not compatible.

2006-09-01 16:17:02 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers