Connecting to Access 2000 using ADO Data Control
ADO(Active Data Objects) is the successor to DAO/RDO. It is a powerful way to link a database to VB. We will do this link using to an Access2000 database.
Note that to make the selection you need to have Selected Items Only unchecked. Later if you only want to see selected items, you can check this and only Microsoft ADO Data Control will appear in the list.
This slide starts the steps of linking the ADO Data Control to the Access Database that I am using.
Note the ADO control on the control line with the other available controls.
When you click on the ..., this screen appears. Now, with Use Connection String and the Build button we can go to the Data Link Properties screen.
On the Data Link Properties screen I am selecting Microsoft Jet 4.0 OLE DB Provider. I will then click the Next button. Note that Jet 3.51 works for Access 97 while Jet 4.0 works for both.
In this slide I clicked on the button next to the space for select or enter a database and brought up the screen where I can make my choice. When I made the selection, the choice showed up on the Data Link Properties form. I then went back and opened the screen with the selection again so I could show it in this picture.
Test Connection is a valuable tool here - it lets you test to see if the connection has been successful. If it is successful, a message will come back saying test connection successful.
After you click OK on the previous slide (Data Link Properties), the Use Connection String is filled in as shown above.
When you click OK on the Property Pages, the Connection String gets filled in.
Next I have to establish the RecordSource. When I click on ... the Property Pages comes up. I pick type 2 adCmdTable as the command type since I am using a table for this project. I then select the table from Table or Stored Procedure Name. The table I am selecting is Donor2000.
When the table or stored procedure name has been selected, press OK.
Now I am putting fields on the form and linking them to the Data Source. On the next slide, I will link the field specifically to the field on the DataSource.
Now I am linking the specific field to DIdno which is a field on the Donor database. I will place name and city on the form as well and link them in the same way.
This is the database and this is the first record on the database which shows when the program is run. You can use the arrows to move through the database.
Note that when I use the ADO Data Control these are the references that are active.
This shows the code for the MoveFirst, MoveLast, MoveNext and MovePrevious associated with the ADODonor.
Note that the update really does not need to be coded. When you move to another record the change is made.
Also note that after the delete I went to the first record to make the delete happen. I could have chosen to go somewhere else or I could have left it up the the user to move.