The Connection String value is used to provide information to connect to a specific SQL server instance. This information includes the server name, database name, the authentication mechanism, and some other important information such as connection timeout and network settings. You specify this type of information as a string value containing pairs of key/value separated by a semicolon (;). The order of listing these pieces of information is not critical; also, you can choose any capitalization you may like. Let's discuss some of the most important and commonly used Connection String Information.
Server: This is the name of the database server instance. Use (local) if the server is on your machine, so the Connection String will look like SqlConn1.ConnectionString = "Server=(local);Database=pubs;Integrated Security=true". I have used the server name MichaelServer because this is the server instance name on my machine, which is also called MichaelServer. To access a SQL server instance on your network, you need to qualify the instance name with the machine name. For example, if the machine is called MickMachine and the server is called MichaelServer, you set MickMachine\MichaelServer to the server. But most of the time you will find that both the machine name and the server name have the same value, and that's all you have to set.
Connection Timeout: The connection timeout is how many seconds the connection waits to establish the connection with the server before generating an error. The default value is 15 seconds. You can read the connection timeout (after you set it here in the connection string) through the ConnectionTimeOut property of a SqlConnection object.
Database: The database that will be used by the connection to issue commands.
Integrated Security: SQL Server uses two different ways to authenticate users. The first way is to use NT authentication in which SQL Server uses your Windows login to access the server (your Windows login must be authorized to access SQL Server in this case). The other way is to use SQL Server authentication, which can be set in the connection string using the next two keys. The integrated security key has the default value of false, which means that it will not be used to connect to the SQL Server, so if you want use it you have to set it to true as we did in our example.
User ID: This is the SQL Server user ID that will be used when you want to access the server using SQL Server authentication.
Password: The password that's associated with the server user ID. If it's an empty password you can use it as in the following Connection String, "Server=(local);Database=pubs;User ID=sa;Password=;"