Solved

Creating DB Connection on load VB.NET to .mdb

Posted on 2009-04-07
5
365 Views
Last Modified: 2013-11-26
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")
0
Comment
Question by:c9k9h
  • 3
5 Comments
 
LVL 12

Accepted Solution

by:
rgn2121 earned 250 total points
ID: 24093634
Here is one way...  What it looks like you are doing is trying to use an old approach (VB6) in VB.Net.  I would suggest reading up on DB connections...
http://www.java2s.com/Tutorial/VB/0480__Database-ADO.net/CreateOleDbConnectiontoAccessdatabase.htm
 
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 24093643
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24093645
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()
0
 
LVL 12

Expert Comment

by:rgn2121
ID: 24093650
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...
0
 

Author Closing Comment

by:c9k9h
ID: 31567846
Perfect!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now