Click to See Complete Forum and Search --> : Pls help me to solve ADO-SQL...???


Dang Ha Vinh
February 27th, 1999, 12:11 AM
Hi,

I have Access file. "Table1" in this file include one field: Field1, type string.

I am using VB6 to use Database with ADO that following:


Dim db as new Connection

set db = new connection

db.open "...;Data Source = ...\MyDatabase.mdb"


Dim adoTest as new Recordset


if I use statement, for instance:

adoTest.Open "SELECT * FROM Table1 WHERE Field1 like '*abc*';", db,...

then adoTest hasn't got any record.


(if I use: like 'abc' then i'll receive a recordset included records that has 'abc' in Field1)


Please help me. Thanks in advance.

Looking forward to hearing from you.

Best regards,

Dang Ha Vinh

EnverM
March 2nd, 1999, 11:43 AM
Try using :


SELECT * From Table1 Where Field1 Like '%abc%'

This way, you retrieve records that contain abc anywhere in Field1.


I.E. Use the percent sign instead of the asterisk.


If you want to limit the search, use


SELECT * from Table1 Where Field1 Like 'abc%'

This way, you only retrieve records starting with abc

J2ms
March 21st, 2000, 01:46 AM
I suppose you want to obtain any registers with the word 'abc' contained in field1.

So that, I suggest you to use (%) instead of (*)

adoTest.Open "SELECT * FROM Table1 WHERE Field1 like '%abc%';", db,...