Results 1 to 4 of 4

Thread: VB and Access Database.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    109

    Question VB and Access Database.

    OK I am totally new to Access, I've created 2 fields in Access
    will say name Username and ID.

    then I saved it.

    nvc.db

    So that is my access file, so now I want to call the access file I have that.

    now does anyone have documentation on how to create a proper Access file.. something simple .. I can create the link with VB to the file..

    thank you all

  2. #2
    Member
    Join Date
    Mar 2000
    Posts
    62
    goto msdn.microsoft.com and do a search on DAO or ADO, ADO preferably. all the simple documentation you need ; )

  3. #3
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Re: VB and Access Database.

    Originally posted by nvc944
    OK I am totally new to Access, I've created 2 fields in Access
    will say name Username and ID.

    then I saved it.

    nvc.db

    So that is my access file, so now I want to call the access file I have that.

    now does anyone have documentation on how to create a proper Access file.. something simple .. I can create the link with VB to the file..

    thank you all
    Open a new project and add a command button to the form.
    Add a reference to "Microsoft ActiveX Data Objects 2.x Library"
    Add this code:

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim rst As New ADODB.Recordset
    3. Dim cnn As String, strFileName As String, strSQL As String
    4.  
    5. strFileName = "C:\Temp.mdb"
    6. strSQL = "SELECT * FROM Login"
    7.  
    8. cnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileName
    9.  
    10. rst.Open strSQL, cnn
    11.  
    12. MsgBox rst!UserName & vbCrLf & rst!Password
    13.  
    14. Set rst = Nothing
    15.  
    16. End Sub

    Of course change the filename(c:/temp.mdb), tablename(Login), and fieldnames(UserName,Password) to match your database.

    That should get you started.
    Last edited by Muddy; Jan 28th, 2003 at 10:10 PM.

  4. #4
    Member
    Join Date
    Mar 2000
    Posts
    62
    goto msdn.microsoft.com and do a search on DAO or ADO, ADO preferably. all the simple documentation you need ; )

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