Вы находитесь на странице: 1из 11

The ADO Data Control

Universal Data Access


Open Database Connectivity (ODBC)
standard for accessing data in databases
OLE-DB
allows access to data in many formats
faster and easier to use than ODBC
Application

ADO

OLE-DB

OLE-DB OLE-DB OLE-DB OLE-DB OLE-DB


Provider Provider Provider Provider Provider

ODBC

ODBC SQL
Access Oracle Excel
Data Server
ADO, DAO and RDO in Visual Basic
In Visual Basic, three data access interfaces are
available to you:
ActiveX Data Objects (ADO)
Remote Data Objects (RDO)
Data Access Objects (DAO)
Data access technology is constantly evolving, and
each of the three interfaces represents a different
stage of development for data access technology.
The latest is ADO. It features a simpler yet
more flexible object model than either RDO or
DAO. For new projects, you should use ADO as
your data access interface.
The ADO Object Model
Four main objects:
* Connection the link between the program
and the data store
* Command allows you to run commands
against the data store
* Recordset contains all the data returned from
a specific action on the data store
* Stream allows the manipulation of data held
in web resources, such as HTML files
Using the ADO Data Control
Add the Microsoft ADO Data Control 6.0 (OLEDB)
component to your project.
Create an instance of the ADO Data Control on your
form.
Connect to a database with the ADO Data Control by
building a connection string.
Set the RecordSource property of the ADO Data
Control
Create bound controls on your form.
Building a Connection String
In the properties window of the ADO Data
controls choose the ConnectionString property.
3 Methods
From the property pages, choose Use Connection
String and choose Build
From the Provider tab in the Data Link Properties
dialog box, specify which data provider to use.
use Microsoft Jet 4.0 OLE DB Provider for Access
databases
choose Next >> to bring up the Connection tab of the
Data Link Properties dialog box
Building a Connection String
Three methods
Use a data Data Link File
Use an ODBC Data Source Name
Use a Connection String

Back
Building a Connection String
From the Connection tab, enter your
database name and path (or browse for it)
Leave the default log on
information
Test Connection
Set the RecordSource property of
the ADO Data Control
In the properties window of the ADO Data controls
choose the RecordSource property.
Choose a Command Type
adCmdUnknown
adCmdTable
adCmdText
adCmdStoredProc
Select a table or enter
an SQL statement
Creating Bound Controls
Many different controls that can hold text
and graphics can be bound to a field in an
ADO Data control.
Set the DataSource property of the bound
control to the ADO Data Control.
Set the DataField property of the bound
control to the field you want to display

Вам также может понравиться