In ASP.Net 2.0 SQL Server Database connection string can also be stored separately in a web.config file that allows you to access the connection string anywhere in the Data Access Layer developed in the ASP.Net web application. ConnectionStrings section feature of ASP.Net 2.0 makes it easy to use single web.config file to store the database connection string that enables you to change the database connection at single a place without searching its usage in the complex code of large web applications. System.Data.SqlClient namespace of ASP.Net 2.0 provides the Data Access methods and functions for SQL Server database.
<connectionStrings>
connectionString="Data Source=.; Initial Catalog=YOUR SQL DATABASE NAME;User ID=YOUR USERNAME;Password=YOUR PASSWORD;"
</add>
</connectionStrings>
Data Source:
You can use the IP address of the web server configured with SQL server or where you have hosted your web site. Mostly in Data Source field localhost is used.
Initial Catalog:
Enter the name of the SQL Database.
User ID and Password:
Enter the MS SQL Server authenticated username and password.
connectionString="Data Source=localhost; Initial Catalog=Northwind;User ID=sa;Password=password;"
Above example of ASP.Net SQL Server database connection string shows the connectivity with default Northwind database with username "sa" and password "password".
Currently rated 5.0 by 1 people
Tags: asp.net 2.0, ado.net, asp.net sql server database connection string, asp.net connectionstring, asp.net web.config, asp.net database connection, asp.net sql connection string, asp.net access connection string, web.config connectionstrings, web.config configuration, odbc microsoft access drivers, oledb connection string, app_data, sql connectionstring
10/11/2008 3:43:03 AM