亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

SQLServer 2005數(shù)據(jù)庫(kù)連接字符串 連接sql2005必備資料

 更新時(shí)間:2010年04月14日 17:21:11   作者:  
現(xiàn)在好多朋友開始用sqlserver 2005了,因?yàn)楦鷖ql2000有區(qū)別,所以這里整理了下,需要的朋友可以參考下。
連接字符串中常用的聲明有:

服務(wù)器聲明 Data Source、Server和Addr等。

數(shù)據(jù)庫(kù)聲明 Initial Catalog和DataBase等。

集成Windows賬號(hào)的安全性聲明 Integrated Security和Trusted_Connection等。

使用數(shù)據(jù)庫(kù)賬號(hào)的安全性聲明 User ID和Password等。

對(duì)于訪問數(shù)據(jù)庫(kù)的賬號(hào)來(lái)說,通常我們?cè)谝恍﹨⒖假Y料上看到ADO.NET的字符串連接往往有如下寫法:
復(fù)制代碼 代碼如下:


string ConnStr = "server = localhost;
user id = sa; password = xxx; database = northwind";

對(duì)于集成Windows安全性的賬號(hào)來(lái)說,其連接字符串寫法一般如下:

復(fù)制代碼 代碼如下:

string ConnStr = "server = localhost;
integrated security = sspi; database = northwind";
或string ConnStr = "server = localhost;
trusted_connection = yes; database = northwind";

使用Windows集成的安全性驗(yàn)證在訪問數(shù)據(jù)庫(kù)時(shí)具有很多優(yōu)勢(shì):安全性更高、訪問速度更快、減少重新設(shè)計(jì)安全架構(gòu)的工作、可以硬編碼連接字符串等,還是很值得使用的。





SQL Native Client ODBC Driver

標(biāo)準(zhǔn)安全連接
復(fù)制代碼 代碼如下:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;


您是否在使用SQL Server 2005 Express? 請(qǐng)?jiān)凇癝erver”選項(xiàng)使用連接表達(dá)式“主機(jī)名稱\SQLEXPRESS”。

受信的連接
復(fù)制代碼 代碼如下:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;


"Integrated Security=SSPI" 與 "Trusted_Connection=yes" 是相同的。

連接到一個(gè)SQL Server實(shí)例
指定服務(wù)器實(shí)例的表達(dá)式和其他SQL Server的連接字符串相同。
Driver={SQL Native Client};Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=yes;


指定用戶名和密碼
oConn.Properties("Prompt") = adPromptAlways

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;


使用MARS (multiple active result sets)

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;MARS_Connection=yes;

"MultipleActiveResultSets=true"與MARS_Connection=yes"是相同的。
使用ADO.NET 2.0作為MARS的模塊。 MARS不支持ADO.NET 1.0和ADO.NET 1.1。

驗(yàn)證網(wǎng)絡(luò)數(shù)據(jù)

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;


使用附加本地?cái)?shù)據(jù)庫(kù)文件的方式連接到本地SQL Server Express實(shí)例

Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

為何要使用Database參數(shù)?如果同名的數(shù)據(jù)庫(kù)已經(jīng)被附加,那么SQL Server將不會(huì)重新附加。

使用附加本地?cái)?shù)據(jù)文件夾中的數(shù)據(jù)庫(kù)文件的方式連接到本地SQL Server Express實(shí)例

Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

為何要使用Database參數(shù)?如果同名的數(shù)據(jù)庫(kù)已經(jīng)被附加,那么SQL Server將不會(huì)重新附加。

數(shù)據(jù)庫(kù)鏡像
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;



SQL Native Client OLE DB Provider

標(biāo)準(zhǔn)連接

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

您是否在使用SQL Server 2005 Express? 請(qǐng)?jiān)凇癝erver”選項(xiàng)使用連接表達(dá)式“主機(jī)名稱\SQLEXPRESS”。

受信的連接

Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;

"Integrated Security=SSPI"與"Trusted_Connection=yes"相同

連接到SQL Server實(shí)例
指定服務(wù)器實(shí)例的表達(dá)式和其他SQL Server的連接字符串相同。
Provider=SQLNCLI;Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=yes;


使用帳號(hào)和密碼
oConn.Properties("Prompt") = adPromptAlways

oConn.Open "Provider=SQLNCLI;Server=myServerAddress;DataBase=myDataBase;


使用MARS (multiple active result sets)

Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;MarsConn=yes;

"MultipleActiveResultSets=true"和"MARS_Connection=yes"是相同的。
使用ADO.NET 2.0作為MARS的模塊。 MARS不支持ADO.NET 1.0和ADO.NET 1.1。

驗(yàn)證網(wǎng)絡(luò)數(shù)據(jù)

Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;Encrypt=yes;


使用附加本地?cái)?shù)據(jù)庫(kù)文件的方式連接到本地SQL Server Express實(shí)例

Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

為何要使用Database參數(shù)?如果同名的數(shù)據(jù)庫(kù)已經(jīng)被附加,那么SQL Server將不會(huì)重新附加。

使用附加本地?cái)?shù)據(jù)文件夾中的數(shù)據(jù)庫(kù)文件的方式連接到本地SQL Server Express實(shí)例

Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

為何要使用Database參數(shù)?如果同名的數(shù)據(jù)庫(kù)已經(jīng)被附加,那么SQL Server將不會(huì)重新附加。

數(shù)據(jù)庫(kù)鏡像
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;



SqlConnection (.NET)

標(biāo)準(zhǔn)連接

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

使用serverName\instanceName作為數(shù)據(jù)源可以指定SQL Server實(shí)例。
您是否在使用SQL Server 2005 Express? 請(qǐng)?jiān)凇癝erver”選項(xiàng)使用連接表達(dá)式“主機(jī)名稱\SQLEXPRESS”。

Standard Security alternative syntax
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;


受信任的連接

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;


Trusted Connection alternative syntax
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;


連接到一個(gè)SQL Server的實(shí)例
指定服務(wù)器實(shí)例的表達(dá)式和其他SQL Server的連接字符串相同。
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;


來(lái)自WinCE設(shè)備的安全連接
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;

僅能用于CE設(shè)備。

帶有IP地址的連接

Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

使用MARS (multiple active result sets)

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;MultipleActiveResultSets=true;

使用ADO.NET 2.0作為MARS的模塊。 MARS不支持ADO.NET 1.0和ADO.NET 1.1。

使用附加本地?cái)?shù)據(jù)庫(kù)文件的方式連接到本地SQL Server Express實(shí)例

Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;

為何要使用Database參數(shù)?如果同名的數(shù)據(jù)庫(kù)已經(jīng)被附加,那么SQL Server將不會(huì)重新附加。

使用附加本地?cái)?shù)據(jù)文件夾中的數(shù)據(jù)庫(kù)文件的方式連接到本地SQL Server Express實(shí)例

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

為何要使用Database參數(shù)?如果同名的數(shù)據(jù)庫(kù)已經(jīng)被附加,那么SQL Server將不會(huì)重新附加。

使用在SQL Server Express實(shí)例上的用戶實(shí)例
Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;

數(shù)據(jù)庫(kù)鏡像
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;

Asynchronous processing
Server=myServerAddress;Database=myDataBase;Integrated Security=True;Asynchronous Processing=True;

相關(guān)文章

最新評(píng)論