Monday, August 2, 2010

SQL Server Express Connection String

1. Working with SQL Client:
1.1 NameSpace: System.Data.SqlClient;
1.2 Objects: DataSet dataSet;
SqlConnection conn;
SqlDataAdapter dbAdapter;
1.3 Connection Strings:

1.3.1 Using Windows Authentication Mode of Connectivity:
string conString = "Server=.\\SQLEXPRESS;" +
"DataBase=yourDatabase;" +
"Integrated Security=SSPI;";

1.3.2 Using SQL Server Authentication Mode of Connectivity:
string conString = "Server=.\\SQLEXPRESS;" +
"DataBase=yourDatabase;" +
"Uid=yourUserId;Pwd=yourPassword;";

2. Working with OLEDB:
2.1 NameSpace: System.Data.OleDb;
2.2 Objects: DataSet dataSet;
OleDbConnection conn;
OleDbDataAdapter dbAdapter;
2.3 Connection Strings:

2.3.1 Using Windows Authentication Mode of Connectivity:
string conString = "Provider=SQLOLEDB;" +
"Data Source=.\\SQLEXPRESS;" +
"Initial Catalog=yourDataBase;" +
"Integrated Security=SSPI;";

2.3.2 Using SQL Server Authentication Mode of Connectivity:
string conString = "Provider=SQLOLEDB;" +
"Data Source=.\\SQLEXPRESS;" +
"Initial Catalog=yourDataBase;" +
"Uid = yourUserId; Pwd = yourPassword;";

No comments: