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\i bdfin$\MIS \Departmen t\Database s\phone memo backend.mdb")
Dim dbMyDB As Database
Dim rsMyRS As RecordSet
dbMyDB = OpenDatabase("\\Ptldat16\i
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.homeandlearn.co .uk/NET/ne ts12p4.htm l
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()
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)
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...
ASKER
Perfect!