Using a .UDL File from ADO

This example illustrates how to assign the ConnectionString property of an ADO connection object by using a .udl file.

Michael Otey

September 20, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Saving your connection properties in a .udl file lets you use them in your ADO application at runtime. Using a .udl file from ADO to connect to SQL Server is very similar to using the standard OLE DB connection string. The following example illustrates how to assign the ConnectionString property of an ADO connection object by using a .udl file.

Dim oConn As New ADODB.ConnectionoConn.ConnectionString = "File Name=c:tempmyUDL.udl"oConn.Open

You can also use the .udl file directly with the ADO connection object's Open method. The next example illustrates how you can use a .udl file as a parameter for the ADO connection object's Open method:

Dim oConn As New ADODB.Connection    oConn.Open "File Name=c:tempmyUDL.udl"

Note that to make this technique work, you need to ensure that the .udl file is in a location that the ADO application can access. For instance, if the application runs from a network-attached system, then the .udl file must reside on the local system or on a network share. If the application is a COM+ or Microsoft Transaction Server (MTS) application, then the .udl file must be accessible from the COM+ application or MTS package.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like