![](/img/trans.png)
[英]string.Equals is not working as I expected in asp.net webforms
[英]connection string is not working in asp.net webforms
我在somee.com上注冊了我的網站。 為此,我已經上傳了MS SQL數據庫。 我在我的代碼中寫了這個連接字符串:
connectionString="metadata=res://*/nrcsaEntities.csdl|res://*/nrcsaEntities.ssdl|res://*/nrcsaEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=My-PC;initial catalog=nrcsa;integrated security=True;multipleactiveresultsets=True;App=EntityFramework""
現在,當我注冊時,somee.com為我提供了新的連接字符串,即:
workstation id=nrcsadb.mssql.somee.com;packet size=4096;user id=DuaZoya_SQLLogin_1;pwd=abcd;data source=nrcsadb.mssql.somee.com;persist security info=False;initial catalog=nrcsadb
我已通過將某些第一個連接字符串替換為somee.com提供的連接字符串來更改了web.config文件中的connectiong字符串
問題:
此替換生成警告:
System.ArgumentException: Keyword not supported: 'user id'.
如何解決這個問題呢?
在web.config文件中。
<connectionStrings><add name="nameofConnection" connectionString="Data Source=servername; Initial Catalog=DatabaseName; User ID=UserName; Password=Password;"/> </connectionStrings>
<system.web>
<compilation debug="false" targetFramework="4.0" /> </system.web>
您可以根據自己的需要編輯目標框架。
來自: http : //dotnet-developers-cafe.blogspot.in/2013/08/create-connection-string-in-aspnet.html
您正在使用實體框架。
實體框架有其自己的連接字符串,其中包含對EF元數據的引用( metadata=...
),以及用於連接到實際數據庫的內部連接字符串。
您需要在provider connection string=...
部分的EF連接設置中插入實際的數據庫連接字符串。
您還需要在其連接字符串中添加multipleactiveresultsets=True
; EF需要該設置。
不要替換整個連接字符串。 您將需要刪除Integrated Security = true部分,並將其替換為user = DuaZoya_SQLLogin_1; password = abcd。
還將數據源更改為nrcsadb.mssql.somee.com。
您幾乎只需要用提供的值替換現有連接字符串中的值即可。
當您使用實體框架時,您的連接字符串將如下所示
<connectionStrings>
<add name="BlogContext"
connectionString="metadata=res://*/BloggingModel.csdl|
res://*/BloggingModel.ssdl| res://*/BloggingModel.msl;
provider=System.Data.SqlClient
provider connection string="data source=[you somee.com connetion string];"" providerName="System.Data.EntityClient" />
</connectionStrings>
您需要做的就是簡單地從somee.com提供的實際連接字符串中更改數據源的值
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.