MSSQL DB Connection Strings with ASP/.NET
Posted by RAJU K, Last modified by Kim S. on 20 February 2016 07:27 PM
Please use following connection string syntax for connecting MSSQL DB from your ASP/.NET scripts.
This is a sample connection string which you can use with MS SQL 2005 / 2008 , ASP.NET 3.5 and above versions.
You need to create below connection string in web.config file.
<add name="myConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=DB_Name;User Id =DB_user;password=DB_Pass;" />
Important Properties to change in connection string:
1) Data Source : This should be your MSSQL server name or server IP address like "localhost" or "18.104.22.168"
2) Initial Catalog: You can find data base full name in plesk panel where you orginally created data base.
3) User Id : Replace with user name you created on top of MSSQL DB in plesk control panel.
4) password: Password of the MSSQL DB user created in plesk control panel.
Once you created connectionString in web.config file, you can use it in your ASP pages to retrive data base.
Note: You can't use same connectionstring on your local PC to connect MSSQL DB server. It won't work as we don't allow remote connections to MSSQL server. It means you have to use/connect to MSSQL DB server through ASP/.NET scripts hosted on same server.