470,636 Members | 1,462 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

how to connect microsoft access to visual absic 6.0?

does anyone who could help me on how to connect access to visual basic. What control am I going to useed and what is its code????? I'm just only wanted to see the simplest way on how to connect each other. BNecause there is many pages on the internet but doesn't suite or not bnle to run on my program.

Hope that you could help me.
Feb 13 '07 #1
3 4411
Step 1 :
In your project select reference --> microsoft activex data object librery 2.1

step 2 :

******In General _ delcarations write the following code
Public cn As Connection
Public adors As Recordset
Dim Sql As String

step 3 :

*********in form_load event write the following code
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.JET.OLEDB.4.0"
cn.ConnectionString = "d:\vb projects\a.mdb" '(select the proper path)

step 4 :
write query when required
Feb 13 '07 #2

If you want the simplest to just connect to the MS Access database...
YOu can use Data COntrol. It simply bind the database to the control..
I wish i attach file here so that i can give you many codes to do that....

Just so show you simple example:
open vb6
create new project
add controls Tetxbox and Data Control

By default the name of Data Control is Data1.

DO this with data1 properties
Databasename - there is a button that you can click to select your database
Recourdsource-select what table are we going to use

For Example You have a TextBox to display a record then,
from textbox properties:

Datasource=<Select the control> e.g. in our example select the Data1
Datafield-This is where you can select what field from your table you want to display.

try to run the program and check how it works...(F5)
Feb 15 '07 #3

In addition you can also do this on coding using the Data Control.Thats the next step the coding part... I hope i'ved answered/help you...

Feb 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by http://www.visual-basic-data-mining.net/forum | last post: by
1 post views Thread by perjorgen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.