0% found this document useful (0 votes)
93 views21 pages

Connecting Access To VB 6 Using Adodc

This document provides instructions for connecting a Visual Basic 6 application to a Microsoft Access database using ActiveX Data Objects (ADO). It describes how to create an Access database with a sample table, add an ADO Data Control and DataGrid component to a VB form, configure them to connect to the Access file and table, and link the form controls to the table fields. Buttons are then added to allow basic CRUD operations on the database records, with code provided for some buttons and notes on coding the rest.

Uploaded by

Elias Petros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views21 pages

Connecting Access To VB 6 Using Adodc

This document provides instructions for connecting a Visual Basic 6 application to a Microsoft Access database using ActiveX Data Objects (ADO). It describes how to create an Access database with a sample table, add an ADO Data Control and DataGrid component to a VB form, configure them to connect to the Access file and table, and link the form controls to the table fields. Buttons are then added to allow basic CRUD operations on the database records, with code provided for some buttons and notes on coding the rest.

Uploaded by

Elias Petros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

lOMoARcPSD|23490018

Connecting Access TO VB 6 Using Adodc

Visual Basic Programming (YMCA comprehensive institute )

Studocu is not sponsored or endorsed by any college or university


Downloaded by Elias Petros ([email protected])
lOMoARcPSD|23490018

CONNECTING ACCESS TO VB 6 USING ADODC


1. Create a database “Dbase” in MS access
2. Create a table “REG” with the following fields

3. Save the database in the “2002-2003” format

4. Open VB 6 program and create the user interface as shown below

1|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

ADDING MICROSOFT ADO DATA CONTROL 6.0 (OLEDB)


COMPONENT
1. Click project on the menu. From the dropdown click Components

2|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

2. From the pop up window select “Microsoft ADO Data Control 6.0 (OLEDB)”.
3. Click Apply then OK

4. A New Tool will be added to the Toolbox as show below

3|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

5. Click Adodc Tool and add it to the form as Shown Below

4|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

Configuring ADODC to connect to Access Database


1. Right Click on Adodc1 and select ADODC Properties as shown below.

2. From the Property Pages “Using connection String” Click on Build

5|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

3. From the Data Link Properties Window select “Microsoft Jet 4.0 OLE DB Provider”

4. Click the Next Button connect to the database as shown below.

6|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

5. Browse to select the database and Test the connection to confirm that it succeeds.
6. From the “Microsoft Data Link” Click “OK”

7|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

7. The Connection string is now created. Apply and Click OK as shown below.

8|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

Configuring ADODC to connect to the Table in Database


1. Click on Adodc 1.
2. From the property window select “RecordSource”.
3. Browse to select the Table.
4. From the property window select “RecordSource”

9|Page

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

5. From the Property Pages Window select


i. Command Type- 2-adCmdTable
ii. Table or Stored Procedure Name- select table of you created in this case “Reg”
iii. Click Apply then OK

6. From the property window the Record Source will now be the table “Reg” as shown below

10 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

Connecting the Fields on the Form to the Fields in the Table


1. Click on the Textbox 1.
2. From the property window select DataSource.
3. Select Adodc1 as the DataSource

11 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

4. From the property window select DataField


5. Select PName as the DataField in the database to Correspond with Textbox1 on Form

6. Repeat Procedure 1 to 5 for Textbox 2 and Textbox 3 to ensure that there are connected to
their corresponding Fields in the Database
7. When you run the program, the First record in the database will appear in the corresponding
Fields. Hence the Form in VB has successfully connected to the Felids in the database.

12 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

CODING THE BUTTONS


ADDNEW Button

UPDATE Button

DELETE Button

EXIT Button

13 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

Add More Buttons to the Form as shown below

FIRST Button

PREVIOUS Button

14 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

NEXT Button

LAST Button

Add Textbox3 and a Search Button as Shown below

15 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

Search Button

NOTE:
1. For the above Code to work, you need change the RecordSource Setting as shown below
2. Apply and click ok

16 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

ADDING AND CONFIGURING A DATAGRID TO THE FORM

1. Click project on the menu. From the dropdown click Components

17 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

2. From the pop up window select “Microsoft DataGrid Control 6.0 (OLEDB)”.
3. Click Apply then OK

4. A New Tool will be added to the Toolbox as show below.

18 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

5. Click DataGrid Tool and Draw it to the form as Shown Below

6. To configure the DataGrid, Click on it


7. From the Property window click DataSource and select Adodc1 as shown below

19 | P a g e

Downloaded by Elias Petros ([email protected])


lOMoARcPSD|23490018

8. Run your program


9. Records in the database should be visible in the DataGrid as shown below

20 | P a g e

Downloaded by Elias Petros ([email protected])

You might also like