配置数据库连接字符串

【翻译】http://www.connectionstrings.com/sql-server-2008#p20

MS SQL Server 2008

Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;

Code Example:

string connectionString = null;
connectionString = "Provider=SQLOLEDB;Server=MINGLE;Database=Northwind;Uid=sa;Pwd=123456";
OleDbConnection cnn = new OleDbConnection(connectionString);
try
{
    cnn.Open();
    Response.Write("Connection Open ! ");
    cnn.Close();
}
catch (Exception ex)
{
   Response.Write("Can not open connection ! ");
}
posted @ 2010-01-28 00:21  风影极光  阅读(262)  评论(0编辑  收藏  举报