By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

how to connect microsoft access to visual absic 6.0?

P: 84
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
Share this Question
Share on Google+
3 Replies


samycbe
P: 83
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)
cn.Open


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

P: 58
Hi....


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

then,
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

P: 58
Hi...

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...



GoodLuck....
Feb 15 '07 #4

Post your reply

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