Escolar Documentos
Profissional Documentos
Cultura Documentos
2. Go to Project References and select Microsoft DAO 3.6 Object Library, as shown in Figure D. (Depending on the version of VB you are using, you will have a corresponding DAO Object Library version, so if you don't have DAO 3.6, use an earlier version instead.) Figure D
DAO object library selected in Project References 3. Add two combo boxes (cboLastNameJet and cboLastNameODBCDirect) and two command buttons (cmdGetDataJet and cmdGetDataODBCDirect) to the form.
4.
We've added some objects to our form. 5. 6. Add the code in to the cmdGetDataJet_Click() event. Add the code shown to the Private SubcmdGetDataODBCDirect_Click() event.
7. Modify strLocation to reflect the location use .mdb database and Set dbJet = wrkJet.OpenDatabase(strLocation &".mdb") to reflect the name of the database. 8. Modify strConn to reflect the DSN name and Password of a remote database.
9. Modify the query in Set rsODBCDirect = conODBCDirect.OpenRecordset("SELECT LastName FROM Employees", dbOpenDynamic) to reflect the query you'd like to run. 10. Press [Ctrl][F5] to run the project. 11. Click the Get Data Jet button and the Get Data ODBC Direct button to obtain data using Microsoft Jet and ODBCDirect, respectively. 12. You should see a screen like the one shown in Figure F. Figure F
The RDO Data Control should appear in your toolbox as shown below:
Put a remote data control (RDC) on your form, and set the properties as follows:
Property Value Name rdoBiblio DataSourceName Biblio SQL select * from authors
Now put three text boxes on the form, and set their Name, DataSource, and DataField properties as follows:
Save and run the program. Notice how it works just like the other data control.
Now change the SQL property of the data control to select * from authors order by author and run the program again. Notice the difference. Change the SQL property back to what it was and add three command buttons to the form, and set their Name and Caption properties as follows:
Put the following code in the cmdNameOrder_Click event: rdoBiblio.SQL = "select * from authors order by author" rdoBiblio.Refresh
Put the following code in the cmdYearOrder_Click event: rdoBiblio.SQL = "select * from authors order by [year born]" rdoBiblio.Refresh
Put the following code in the cmdIDOrder_Click event: rdoBiblio.SQL = "select * from authors order by au_id" rdoBiblio.Refresh
Save and run the program and see what happens when you click the buttons.
below: