Solved

Creating DB Connection on load VB.NET to .mdb

Posted on 2009-04-07
5
366 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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