Tuesday, 12 October 2010

How to use UDL File to create sql connection string


1. On a directory of your choosing, create file with UDL extension i.e. test.UDL
2. Open the file icon and a wizard will appear.

3. Create your connection string. First (in the first tab) chose appropriate Provider. Then (in the second tab) construct the Connection by filling the required information (servername, database or similar).
4. Test Connection. If the connection is successful, click OK.
5. Open the UDL file with NOTEPAD
In notepad, you will have the connection string like this
[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;User ID="";Initial Catalog=MySampleDB;Data Source=.;Initial File Name="";Server SPN=""
The wizard has constructed the connection string. This is for SQL Server. Copy the bolded part and use it as connection string in your application.

No comments:

Post a Comment