On Wiring Up an ADO Data Control - Testing the ODBC Data Source Name Option (Page 4 of 4 )
Similar to the DataLink option test, a form and a textbox will be used. The ADODC control settings are as shown. The DSN name created earlier will be browsed to choose it from the list of DSNs available. The authentication in this case will be the appropriate one for the Oracle Server.

For the record source, a table from the Oracle 10G XE database is chosen as shown.

When this form is run you will see the first name of the Employee as shown since the textbox was configured so that the DataField was set to look at First_Name.

Using and Testing the Connection String Option
Again place the ADODC control on the form and choose the option to use the Connection string as shown. Click on the browse button which opens up the datalink window as shown. This is the same as the first option, but the string is created inside the program. Since we will be connecting to a SQL 2005 Server we will use the SQL Native Client driver as shown.

In the Connection tab the other related information is entered as shown. The SQL 2005 server MYSORIAN is on a networked machine named HODENTEK. Appropriate login information must be added, which allows you to choose the database. When you click on the OK button in the window above, the connection string information will be added as shown. In the connection string, the password has been doctored to mask the clear text for this picture.

After entering the authentication information, the Suppliers table was chosen as the RecordSource. For the textbox, the CompanyName was used as the chosen DataField to be displayed.

When this form was run the following information was displayed.

Summary
Connecting the ADODC control to the data source is greatly facilitated by the support provided by this control. The connection can be to any type of database for which appropriate drivers are available. However while using a DataLink file created outside the Visual Basic program, the Microsoft Data Link file may present some problems. This is especially true for the Windows XP operating system. While the Data Link file shows a successful connection when it is tested by itself, it may produce a design time error in the VB program. This is probably because the connection string constructed from the utility may not be format-compatible (Unicode vs. text) to what the VB program is expecting.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |