hello, I'm making an enrollment and billing system and I'm just going to ask how do I connect a database in visual basic? I'm using vb 6 and ms access

Recommended Answers

All 4 Replies

There are several very good sections about it in the Help file. If you just want to use an ActiveX control, go to the Project/Components menu item, and select "Microsoft ADO Data Control 6.0 (OLEDB)". Plop one onto your form and set the properties.

If you want more control over your data (for instance, to use the same recordset on multiple forms or in some other background process), use the ADODB library. Open the VB6 help, go to the Search tab and enter "ADODB". Down about 15 lines, there's a section entitled "Establishing a Connection to a Database". Go to that help topic and scroll down until you find the section entitled "ADO". It has all the basics.

For this method, you will have to set the appropriate references using the Project/References menu item. Look for "Microsoft ActiveX Data Objects 2.8 Library" and "Microsoft ActiveX Data Objects Recordset 2.8 Library". Advantages to this method are that it takes less memory than the ActiveX Data Object control, and you have more options as to when to open/close, update, etc.

The only other thing you'll need to use the ADODB objects is the value for a Connection String. Use this (with suitable changes to fit your situation, of course):

' mostly copied from the Help File '
Const ConnectionString = "provider = microsoft.jet.oledb.4.0;data source = c:\working\db1.mdb"

That will give you a good start, and probably help a bunch and give you some ideas about how to refine your Google searches if you need more details.

Hope this helps. Good luck!

You can also use ADODB connectors. What kind of database will you use? MySQL, Oracle, PostgreSQL, MSAccess, SQLLite, etc...

Have a look at THIS link, it contains all the connection strings you might need to connect to an Acess database.

A data source relationship is a service in information technology that allows customer application to connect with data source hosting server application, whether on the same machine or not. A relationship is required to send orders and get solutions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.