SQL Server連線字串

2022-03-29 09:03:01 字數 1124 閱讀 1194

通常,連線sql server有兩種方式:使用oledb或者sqlclient進行連線。

//標準連線方式

connectionstr = "provider = sqloledb; data source = (local); initial catalog = databasename; user id = ***; password = ***";

//信任連線方式:

connectionstr = "provider = sqloledb; data source = (local); initial catalog = databasename; integrated security = sspi";

注意:integrated security=true 用於 oledb 提供程式時會引發異常。當將該屬性改為true時,會引發異常,無法開啟資料庫連線。
sqlclient進行連線分為使用windows身份驗證和使用sql server 身份驗證方式。

connectionstr = "persist security info=false;integrated security=true;initial catalog=databasename;server=(local)";

或connectionstr = "persist security info=false;integrated security=sspi;database=databasename;server=(local)";

或//integrated security=true 用於 oledb 提供程式時會引發異常

connectionstr = "persist security info=false;trusted_connection=true;database=databasename;server=(local)";

connectionstr = "persist security info=false;user id=sa;password=sa;initial catalog=databasename;server=(local)";

sqlserver連線字串

string strconnection data source localhost database dbname uid sa pwd 111 provider sqloledb string strconnection provider sqloledb data source 2009020...

sql server 連線字串

sqlserver 資料庫常用連線字串 使用者名稱和密碼驗證的方式去連線到資料庫伺服器 windows驗證的方式去連線到資料庫伺服器 integrated security true 的意思是整合驗證,也就是說使用windows驗證的方式去連線到資料庫伺服器。這樣方式的好處是不需要在連線字串中編寫使...

sqlserver連線字串

string strconnection data source localhost database dbname uid sa pwd 111 provider sqloledb string strconnection provider sqloledb data source 2009020...