Connect VB project to MS Access database (1 Viewer)

buratti

Registered User.
Local time
Today, 07:40
Joined
Jul 8, 2009
Messages
234
I have mastered just beyond the basics of VBA and now am trying to learn a little VB. Just for learning purposes I am trying to recreate one of my completed Access database in Visual Basic. I downloaded Visual Studio 2008 Express Edition. I realize that in VB you cannot have bound forms as you can in Access, so I want to connect my VB project to my current Access database tables. I theoretically know how I would add, access, modify, delete, etc. my data without having those bound forms. I would use (and am only assuming that this would be the right way) SQL statements and recordsets to manipulate data and populate fields, etc. So my problem is, how do I originally connect to my Access database? I found the option to "connect to Database..." under the Tools menu, and successfully connected to my Access database, but now have no clue on how to use/reference it in my code. In the left pane of my Visual Basic window I now see the Database Explorer window which lists all my tables, fields in those tables, and even what appears to be my saved queries and functions. How do I now use this in my code?
For a simple example lets just say I wanted to make a simple form that shows the Name Address and Phone number for records in my Customers table from my Access database. I would understand the code behind setting the values of the fields/controls, and could figure out the code for navigating to the previous/next records, but its just that initial connection and opening of a recordset or referencing a table in an SQL statement that I cannot figure out. BTW, can I even use recordsets and SQL in VB as I can in VBA?
 

the_net_2.0

Banned
Local time
Today, 06:40
Joined
Sep 6, 2010
Messages
812
I'm not sure if this is relevant in 2008, but I know that in VB6 the way to open an Access database is:

Code:
opendatabase(path here)

so if that helps, great! :)
 

Users who are viewing this thread

Top Bottom