---
title: "Connection String"  
description: "When application connects to a database or a data file, ADO or ADO.Net utilize a provider to do the job. The connection string contains the informatio"  
author: "Anonymous User"  
published: 2010-07-23  
updated: 2017-11-29  
canonical: https://www.mindstick.com/articles/17/connection-string  
category: ".net"  
tags: [".net"]  
reading_time: 2 minutes  

---

# Connection String

When application connects to a database or a data file, ADO or ADO.Net utilize a provider to do the job. The connection string contains the information that the provider needs to know to be able to establish a connection to the database or the data file.

Connection string defines which database server we are using, where it resides, user name and password and database name.

**Example:**

string strConnection = "Server=abc\\SQLEXPRESs;Database=Employee;Trusted_Connection=True";

##### SQL Server Connection Strings

Common connection strings for the .NET SqlConnection object.

##### Trusted Authentication

Trusted authentication uses the security credentials of the current user to make the connection to SQL Server.

Data Source=*ServerName*; Initial Catalog=*DatabaseName*; Integrated Security=SSPI;

ServerName can be the name of a server or the name of a SQL Server instance such as Server1. ServerName can also be expressed as an IP address. SSPI stands for Security Support Provider Interface.

##### SQL Server Security Authentication

In SQL Server Security Authentication Server stores the Username and Password.

Data Source=*ServerName*; Initial Catalog=*DatabaseName*; User Id=*UserName*; Password=*UserPassword*;

##### Setting the Application Name

Setting the application name makes it very easy to find out what applications are issuing particular SQL statements against the database.

Data Source=*ServerName*; Initial Catalog=*DatabaseName*; Integrated Security=SSPI; Application Name=*MyAppName*;

Whatever text assigns to Application Name will appear in a couple of different places:

- It will be displayed in Profiler under the Application Name column.
- It will be shown in the output of **sp_who2** in the Program Name column.
- It will be shown in the Activity Monitor in the Application column
- It will appear in the program_name column.

---

Original Source: https://www.mindstick.com/articles/17/connection-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
