Results 1 to 4 of 4

Thread: Unable to pull information from access DB

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    2

    Unable to pull information from access DB

    I am trying to use an sql statement to retreive data from an access database using "Like" but it doesnt seem to be working. I have a field called LName which contains last names. I am trying to select all last names that begin with "A". I have verified that there are several names starting with "A" and the field and database names are correct. If I go into access and create a query and view that query it collects the data correctly. Also if I use the same code below without the Like it pulls in the entire database correctly.

    SetNavButtons 3
    Set conMyDB = New ADODB.Connection
    Set rsCust = New ADODB.Recordset
    conMyDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & App.Path & _
    "\phonebook.mdb"
    conMyDB.Open

    rsCust.Open "SELECT * FROM tblCust Where LName Like 'A*' Order By LName", conMyDB, adOpenDynamic, adLockOptimistic

    PopFields
    SetFields False
    SetActionButtons 1

    I also tried saving the query in access and calling it from VB with the same result. The result is Either EOF or BOF is true. basically it seems it is not pulling in any data.

    The syntax I used to try and call the query is below. Either method will be fine. I just need to get one or the other to work.

    'rsCust.Open "SELECT * FROM qryA", conMyDB, adOpenDynamic, adLockOptimistic
    'rsCust.Open "qryA", conMyDB, adOpenDynamic, adLockOptimistic


    Any help would be appreciated.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: Unable to pull information from access DB

    When using SQL statement instend of using the asterick "*" is the percent sign "%" as the wildcard.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    2

    Re: Unable to pull information from access DB

    Bless you Bless you Bless you. I have been beating my head against this for hours trying everything I knew possible lol

    Thank you for your help

  4. #4
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: Unable to pull information from access DB

    Here's a link to the microsoft page on wildcards.

    Microsoft
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

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