Results 1 to 4 of 4

Thread: specifying the database to query

  1. #1
    Guest

    Post

    Okay, this may sound ignorant, but I'm having a prob getting my VB project to recognize the Access database as where all SQL queries are to hit. Everything I've read in Help & Mastering VB 6.0 shows sample code of client side applications hitting a SQL DB on a server somewhere. My Access database is on the same computer where the VB project stays. How do I define this database (only one table) as the source for the one SQL query string in my code?

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    You can use DAO object library. Add a reference to Microsoft DAO library 3.51 (or select the highest version you have installed on your computer). Also, add a listbox to your form. Then you can use this code:
    Code:
    Dim db As Database
    Dim rs As Recordset
    
    Set db = Workspaces(0).OpenDatabase("C:\MyDB.mdb") 'Change this to appropriate path
    Set rs = db.OpenRecordset("MyTable", dbopenTable)
    Do Until rs.EOF
        List1.AddItem rs("Name")
        rs.MoveNext
    Loop
    Assuming that I have a table called MyTable and a field in that table called Name.

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



    [This message has been edited by Serge (edited 12-14-1999).]

  3. #3
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    I don't know a whole lot about Access databases, but do they accept SQL statements? Or do they have their own set of codes? You might look into that.

    ------------------
    Ryan
    [email protected]
    ICQ# 47799046


    [This message has been edited by Gimpster (edited 12-15-1999).]

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Yes, Access accepts SQL.

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