CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 1999
    Posts
    1

    Pls help me to solve ADO-SQL...???



    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

  2. #2
    Join Date
    Mar 1999
    Posts
    1

    Re: Pls help me to solve ADO-SQL...???



    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

  3. #3
    Join Date
    Mar 2000
    Location
    Alcoy (Alicante) Spain
    Posts
    2

    Re: Pls help me to solve ADO-SQL...???

    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,...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured