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.
September 20, 2000
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.
About the Author
You May Also Like