|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
ADOMicrosofts latest set of data access objects are the ActiveX Data Objects (ADO). These objects let you access data in a database server through any OLE DB provider. ADO is intended to give you a consistent interface for working with a wide variety of data sources, from text files to ODBC relational databases to complex groups of databases. The way Microsoft implements connections to all those data sources is with the OLE DB set of COM interfaces, but that standard is a very complex one. Our interface to that interface, so to speak, is ADO, a set of objects with properties, events, and methods. Here are the ADOs:
ADO also includes the Remote Data Service (RDS), with which you can move data from a server to a client application or Web page, manipulate the data on the client, and return updates to the server in one round-trip. In this chapter, were going to use the ADO data control to handle our ADO work. The ADO Data Control The ADO data control is similar to the data control and the remote data control. The ADO data control is designed to create a connection to a database using Microsoft ActiveX Data Objects (ADO). At design time, you create a connection by setting the ConnectionString property to a valid connection string, then set the RecordSource property to a statement appropriate to the database manager. You can also set the ConnectionString property to the name of a file that defines a connection (the file is generated by a Data Link dialog box, which appears when you click ConnectionString on the Properties window and then click either Build or Select). You then connect the ADO data control to a data-bound control such as the data grid, data combo, or data list control by setting its DataSource properties to the ADO data control. At runtime, you can set the Provider, ConnectionString, and RecordSource properties to change the database. Well see how to work with the ADO control in this chapter. Well use controls like the data control, the remote data control, and the ADO data control with bound controls. The Data-Bound ControlsYou can bind certain controls to the data control, the remote data control, and the ADO data control, and those controls are called bound controls. To bind a control to a database control, you use properties like DataSource to specify the database control, and then use properties like DataField or BoundColumn to specify what field to display in the bound control, as well see. Here are the controls that can function as bound controls:
In addition, there are special controls that are designed to be used as bound controls:
Finally, a number of bound controls are specially built to be used with the ADO control only:
Well see these controls at work in this chapter. 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 SolutionsCreating And Managing Databases With The Visual Data ManagerYou can create and manage databases with the Visual Data Manager. Open this tool from the Visual Basic Add-Ins menu, as shown in Figure 24.3.
You can use this tool to create and modify databases. You create a new database with the File menus New item and open an existing database with the Open item. Lets see an example. Here, well create a new database with the Visual Data Manager. Click the Table Type Recordset button, which is the button at the extreme left in the toolbar, and the Use Data Control On New Form button, which is the fourth button from the left. Next, select the New item in the File menu. The Visual Data Manager lets you design databases in several different formats; for this example, choose Microsoft Access Version 7 MDB or later. The Visual Data Manager asks you for a name and path for this new database; well call it db.mdb, so enter that name now and click on OK. Thats itnow weve created a new database, db.mdb. Well add a table to it in the next topic.
|
|
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. |