|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
ADOAs we saw in the last chapter, ActiveX Data Objects (ADO) access data from OLE DB providers. The Connection object is used to specify a particular provider and any parameters. To connect to a data source, you use a Connection object. Using that connection, you can create a new record set, and using the Recordset objects methods and properties, you can work with your data. An ADO transaction marks the beginning and end of a series of data operations that are executed across a connection. ADO makes sure that changes to a data source resulting from operations in a transaction either all occur successfully, or not at all. If you cancel the transaction or one of its operations fails, then the result will be as if none of the operations in the transaction had occurred. In this chapter, well see how to create connections using the ADO Connection object and how to open data providers, creating an ADO Recordset object. Well read data from the data provider and see how to display and modify it. In fact, well see how to support data-bound controls directly in code. Although the ADO model is a complex one, and OLE DB is even more complex, well see that many of the core ADO Resultset methods are the same as the DAO Resultset methods.
Thats it, then, for the overview of databases. Weve seen how the process works in overview; now its time to turn to the Immediate Solutions. Immediate SolutionsA Full-Scale DAO ExampleTo illustrate DAO data handling in code, well build a fully functional DAO projectthe daocode project. This program has a File menu with the following items:
Using The Daocode Example To Create And Edit A DatabaseTo create a database file, select the New Database menu item. Next, add a table to that database with the New Table menu item, then add records to that table. When youre ready to store the database on disk, use the Close Database item.
In addition, the program has buttons that let users add, edit, update, and delete records, as well as letting them move through a database, as shown in Figure 25.1. Each time you want to add a record (including when you enter the first record of a new database), click the Add New Record button, type in the data for the records fields, and click the Update Database button to update the database.
To edit a record, open the record, click the Edit button, edit the data in the records fields, and click the Update Database button to update the database. For simplicity, this program only creates tables with two fields, although you can place as many records as you like in each table. Well develop the code for this example program in the next several topics of this chapter. For reference, the main form of this example program is located in the daocode folder on this books accompanying CD-ROM; the form the user uses to specify the names of the fields in a new table is located in the TableForm folder on CD-ROM; and the code for the form in which the user can enter a text string to search for is located in the SearchForm folder on the CD-ROM.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |