[英]Writing a connection string to access a remote SQL Server database
我的數據庫托管在遠程服務器上。 我需要編寫我必須包含在web.config
文件中的連接字符串。
server name -- abcs.efgh.ed-1.eee.sss.com,1433 (it also contains a port as well)
username -- a
password -- a
db name -- mydb
我知道如何連接到本地數據庫,我用來引用connectionstring.com作為參考,但是連接到遠程數據庫對我來說是一個問題。 請幫助
更新 :
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient"
connectionString="abcs.efgh.ed-1.eee.sss.com,1433;Integrated Security=True;User ID=a;Password=a" />
</connectionStrings>
我得到的例外是:
登錄失敗。 登錄來自不受信任的域,不能與Windows身份驗證一起使用。
實際上,我不想使用Windows身份驗證。 這是我想要的SQL Server身份驗證。
您遇到錯誤,因為您使用“integrated security = true”進行連接。 使用此網站構建您的連接字符串。 http://www.developerfusion.com/tools/sql-connection-string/
我使用網站使用您的輸入生成此連接字符串:
Data Source=abcs.efgh.ed-1.eee.sss.com,1433;Initial Catalog=mydb;Integrated Security=False;User ID=a;Password=a
Put Integrated security =false.
在連接字符串中
如果為false,則在連接中指定用戶ID和密碼。 如果為true,則使用當前Windows帳戶憑據進行身份驗證。 識別的值是true,false,yes,no和sspi(強烈推薦),這相當於true。 如果指定了用戶ID和密碼並且Integrated Security設置為true,則將忽略用戶ID和密碼,並將使用Integrated Security。 SqlCredential是一種更安全的方法,用於為使用SQL Server身份驗證的連接指定憑據(Integrated Security = false)。
更多在這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.