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.
string strConnection = "Server=abc\\SQLEXPRESs;Database=Employee;Trusted_Connection=True";
SQL Server Connection Strings
Common connection strings for the .NET SqlConnection object.
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.