Microsoft
Office 2000 Developer |
|
Creating a Data Source Using the ADO Data Control
See Also
The ADO Data Control (ADODC) is a data source that differs from the Data Environment designer in a few significant ways.
-
The ADO Data Control allows only one connection at a time.
-
The ADO Data Control features a graphic interface that allows the user to move from one record to the next or jump to the beginning or end of a recordset.
-
The Date Environment designer only works from a stand-alone project.
-
The Date Environment designer has a more user-friendly environment for specifying connections to databases.
The ADODC allows you to quickly create connections between data-bound controls and data providers using the simplicity of ADO. For Office developers who are comfortable with RDO, ADODC is similar in function, but is significantly more powerful than RDO.
For More Information For an overview of the ADO Data Control, see "Using the ADO Data Control" in the Visual Basic Programmer's Guide. For reference information, see ADO Data Control.
To create a data source using the ADO Data Control
-
Draw an ADO Data Control on a host form. See Activating and Inserting Controls for information.
-
Right-click the new control, and click ADODC Object. Then click ADODC Properties to display the ADODC Properties dialog box.
-
On the General tab, select a Source of Connection option:
-
Use Data Link File A file format that contains a connection string (see "Use Connection String" later).
-
Use ODBC Data Source Name The name of a DSN found on the current machine.
-
Use Connection String A string that the OLE DB provider understands and translates into a viable connection. Clicking Build and using the Data Link Properties dialog box to build the string automatically generates this string.
-
If the database requires a user ID and a password, click the Authentication tab, and fill in the User Name and Password boxes.
-
Click the RecordSource tab.
-
From the Command Type list, select an option. The options are a subset of those available for the ADO Recordset object's CommandType property, which specifies how the record source text will be evaluated:
-
adCmdUnknown Default. The type of command is not known. If selected, the Command Text (SQL) text box becomes active allowing you to directly type in an SQL statement or other string appropriate to the database.
-
adCmdText Evaluates the command as a textual definition of a command or stored procedure call. If selected, the Command Text (SQL) text box becomes active allowing you to directly type in an SQL statement or other string appropriate to the database.
-
adCmdTable Evaluates the command as a table name whose columns are all returned by an internally generated SQL query. If selected, the Table or Stored Procedure Name list becomes active and filled with selectable names of tables.
-
adCmdStoredProc Evaluates the command as a stored procedure name. If selected, the Table or Stored Procedure Name list becomes active and filled with selectable names of stored procedures.
-
Click OK.
The ADO Data Control is a visual tool that allows you to quickly and easily configure a data source at design time.
To configure the ADO Data Control data source
-
Set the correct OLE DB provider.
-
Set the path to the database.
-
Set user name and password if needed.
-
Set read/write privileges.
-
Set other settings that initialize the database.