Link to home
Start Free TrialLog in
Avatar of c9k9h
c9k9h

asked on

Creating DB Connection on load VB.NET to .mdb

I'm attempting to open a connection to an .mdb file via vb.net It seems pretty straight forward but can't seem to get it getting "type not defined" for the first and second lines... Any help is always appreciated!

 Dim dbMyDB As Database
    Dim rsMyRS As RecordSet

dbMyDB = OpenDatabase("\\Ptldat16\ibdfin$\MIS\Department\Databases\phone memo backend.mdb")
ASKER CERTIFIED SOLUTION
Avatar of rgn2121
rgn2121
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Something in this order:
Dim dbE As DAO.DBEngine
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Dim strCon As String
        Dim x, y As Integer

        dbE = New DAO.DBEngine()
        strCon = "Northwind.mdb"
        db = dbE.OpenDatabase(strCon)
        rs = db.OpenRecordset("Products")
        rs.Index = "ProductName"
        rs.MoveFirst()
        For x = 0 To 5
            For y = 0 To 5
                Console.Write(rs.Fields(y).Value)
            Next
            Console.WriteLine()
            rs.MoveNext()
        Next
        rs.Close()
        db.Close()
There is also a "Forms over Data" video series for VB.Net on the Web that will walk you through using the designer if that is how you decide to go.  It uses SQL Express, but the logic of it is pretty much the same...
Avatar of c9k9h
c9k9h

ASKER

Perfect!