Go to Comments





Basic database connection string C# and Sql Server using UDL file


Created: 15/06/2013 09:26:26 p.m.





Basic database connection string C# and Sql Server using UDL file

This is a simple way to get proper database connection String to use in your project.

Microsoft Sql Server

1) First i show my Sql Server databse



2) Open notepad.exe and save empty file like "All files" and "conn.UDL" file



3) After creation of your file double click and in the first flap select Microsoft OLE DB Provider for SQL Server




4) In the second flap select your Sql Server name, then press Use Windows NT Integrated security, and finally select your DataBase from the selected Server




5) If you whant you can test the options that you have selected, like here below.


6) After all, open that file with simple notepad.exe and copy all the created string, so you can use it in your project.


7) You can delete the first parameter, Provider=SQLOLEDB.1;

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=tests;Data Source=MAK-PC\MSSQLSERVER2008

Result: 
Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=tests;Data Source=MAK-PC\MSSQLSERVER2008


Hope this helps somebody!
Let me your comment.




Comments:

User: Wiccio Comment date: 15/06/2017 07:31:00 a.m.
Thanks so much for your detailed (and photographical) guide, Ive found it very helpful. Now I just need to figure out how to point the .udl file inside the project, I hope I can do it!
User: Docstorus Comment date: 20/06/2017 07:41:00 p.m.
@Wiccio In general i use .udl file only to generate the connection string, then i open that file with notepad, and copy the content (connection string) and past it inside your web.config for ex.