Create a SQL ConnectionString Easily

Here’s a trick I found to create a SQL ConnectionString quickly and easily. Beginning developers may find this useful.

1. Create a new text file with a UDL extension (i.e. sql.udl).
2. Right-click on the file and click “Properties”.
3. On the “Provider” tab, ensure you select “Microsoft OLE DB Provider for SQL Server”.
4. On the “Connection” tab:
- Enter the Server Name. Be advised the “Server name” drop-down list may take some time to populate.
- Enter the username and password of an account on the SQL Server.
- Check the “Allow saving password” checkbox.
- In the “Select the database on the server” dropdown list, type the name of your database.
5. Click “Test Connection”. If you get a message saying it succeeded, you’re done. Otherwise, goto step 3.
6. Click OK. If you get an error regarding the security of saving a password in plain text, click OK there too. After all, your connectionstring will have to contain the database password and your web.config will generally store it in plaintext anyway. If you’re security-concious, just make sure that’s all the account has access to.
7. Open the UDL file in NotePad. The contents are your connectionstring in plaintext, ready to be copied and pasted to your IDE of choice. Be sure to delete the UDL file afterwards to eliminate security and clutter concerns.