?
Solved

Creating DB Connection on load VB.NET to .mdb

Posted on 2009-04-07
5
Medium Priority
?
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 12

Accepted Solution

by:
rgn2121 earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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