Using UDL Files

The OLE DB .NET Data Provider supports Universal Data Link (UDL) file names in its connection string. You can pass the connection string by using construction arguments to the OleDbConnection object, or you can set the connection string by using the object's ConnectionString property.


Note   The SQL Server .NET Data Provider does not support UDL files in its connection string. Therefore, this approach is available to you only if you are using the OLE DB .NET Data Provider. 


For the OLE DB provider, to reference a UDL file with the connection string, use "File Name=name.udl."


Advantages

  • Standard approach. You might already be using UDL files for connection string management.

Disadvantages

  • Performance. Connection strings that contain UDLs are read and parsed each time the connection is opened.
  • Security. UDL files are stored as plain text. You can secure these files by using NTFS file permissions, but doing so raises the same issues as with .config files.
  • SqlClient does not support UDL files. This approach is not supported by the SQL Server .NET Data Provider, which you use to access SQL Server 7.0 and later.

More Information

  • To support administration, make sure that administrators have read/write access to the UDL file and that the identity used to run your application has read access. For ASP.NET Web applications, the application worker process runs by using the SYSTEM account by default, although you can override this by using the <processModel> element of the machine-wide configuration file (Machine.config). You can also impersonate, optionally with a nominated account, by using the <identity> element of the Web.config file.
  • For Web applications, make sure that you do not place the UDL file in a virtual directory, which would make the file downloadable over the Web.