Configuring an SQL Server Connection String
The SQL Server provider enables you to access SQL Server 7.0 and later. If you need to connect to SQL Server 6.5 and earlier, use the OLEDB provider. The classes are located in the System.Data.SqlClient namespace.
Following code creates and opens a connection to an SQL Server database using the SQL Server .NET data provider using integrated security and SQL Server authentication
using System;
using System.Data.SqlClient;
namespace SqlServerConnectionString
{
class Program
{
static void Main(string[] args)
{
// Connect using SQL Server data provider and integrated security
string sqlConnectString = "Data Source=(local);Integrated security=SSPI;Initial Catalog=AdventureWorks;";
using (SqlConnection connection = new SqlConnection(sqlConnectString))
{
string sqlSelect = "SELECT TOP 4 ProductID, Name, ProductNumber FROM Production.Product";
SqlCommand command = new SqlCommand(sqlSelect, connection);
// Execute the DataReader
connection.Open();
SqlDataReader reader = command.ExecuteReader();
// Output the data from the DataReader to the console
Console.WriteLine("ProductID\tProductName\t\tProductNumber\n");
while (reader.Read())
Console.WriteLine("{0}\t\t{1}\t\t{2}\n\n", reader[0], reader[1], reader[2]);
}
// Connect using SQL Server data provider and SQL Server authentication
string sqlConnectString1 = "Data Source=(local);Initial Catalog=AdventureWorks;User Id=sa;Password=password;";
using (SqlConnection connection = new SqlConnection(sqlConnectString1))
{
string sqlSelect = "SELECT TOP 4 Title, FirstName, LastName FROM Person.Contact";
SqlCommand command = new SqlCommand(sqlSelect, connection);
// Execute the DataReader
connection.Open();
SqlDataReader reader = command.ExecuteReader();
// Output the data from the DataReader to the console
while (reader.Read())
Console.WriteLine("{0} {1} {2}", reader[0], reader[1], reader[2]);
}
Console.WriteLine("\nPress any key to continue.");
Console.ReadLine();
}
}
}

Mukesh KumarPosted Jun 29, 2011, 3:06 PM
Integrated security : Used to connect to SQL Server by using a secure connection when authentication is through the user’s domain account. Can be set to true, false, or sspi. The default is false. When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication. sspi (strongly recommended) is equivalent to true.
Sandeep ShekhawatPosted Jun 29, 2011, 10:37 AM
One time u use Integrated security=SSPI and Next time u use Integrated Security=True and When use Sql Server Authentication then u do not pass it what is this i confuse with it please explain?