2
我一直在關注本教程以使用安裝程序來安裝數據庫腳本。但它只適用於SQL登錄憑據。如何使visual studio中的sql數據庫安裝程序安裝使用Windows身份驗證?
Walkthrough: Using a Custom Action to Create a Database at Installation
我如何使用Windows身份驗證憑據這項工作?
我一直在關注本教程以使用安裝程序來安裝數據庫腳本。但它只適用於SQL登錄憑據。如何使visual studio中的sql數據庫安裝程序安裝使用Windows身份驗證?
Walkthrough: Using a Custom Action to Create a Database at Installation
我如何使用Windows身份驗證憑據這項工作?
對於C#,您可以從下面開始:查看是否可以打開連接。 如果您未使用本地主機,請將其更改爲服務器地址。
public class SQLconn{
public SqlConnection myConnection = new SqlConnection("user id=xxx;" +
"password=xxx;server=localhost;" +
"Trusted_Connection=yes;" +
"database=dbname; " +
"connection timeout=30");
public void connect(){
try {
myConnection.Open();
}catch (Exception e){
MessageBox.Show(e.ToString());
}
}
}
該鏈接不再工作了 –