Connection string example in asp net

In this asp .net tutorial we will learn how to declare connection string in web.config file and how to use connection string in our website pages. Connection string holds information that is required to communicate with the database. You can use connection string with any database like MSSQL, MySQL, MS Access etc.


Some of the main parameters present in Asp .Net connection string are:

1) “name”: Name of the connection stirng.

2) "Data Source": Name of the Sql Server Instance.

3) "Initial Catalog": Name of database you want to communicate with.

4) "User ID": User Name you have created to login into SQL Server.

5) "Password": Password you have created to login into SQL Server.

6) "providerName": This varies based on database we are using.

            E.g. If we are using MsSql Server then provider is: “System.Data.SqlClient” 

            If we are using MySql server then provider is : “MySql.Data.MySqlClient”



In this article we will use connection string to communicate with MsSql Server database. We will create two types of connection strings:


1) Connection string using Windows Authentication.

2) Connection string using SQL Server Authentication.


Connection string using Windows Authentication:

In this scenerio there is no need to specify user name and password of SQL server.  Instead of username and password we use “Integrated Security=True"






Connection string using Sql Server Authentication: 





Asp.Net Ajax Control Toolkit tutorials.

Give your valuable comments.

5 + 6 =

About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice