1

我有一个带有 SQL Server 2008 R2 数据库的 ASP.NET C# 应用程序,该数据库具有整合的成员资格提供程序和应用程序数据库。我正在尝试根据网络托管服务提供商提供的说明修改我的网络配置,但我认为我遗漏了一些东西。

这是我当前的 web.config 连接字符串:

<connectionStrings>
<add name="RestaurantDB" connectionString="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Integrated Security=SSPI;"/>

<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

</connectionStrings>

这是网络托管服务给我的连接字符串:

Data Source=RESTAURANT.db.9319451.hostedresource.com; Initial Catalog=RESTAURANT; User ID=your username; Password='your password';

如何根据上述情况修改我当前的连接字符串?提前致谢。

4

2 回答 2

1

只需更换data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Integrated Security=SSPI;

Data Source=RESTAURANT.db.9319451.hostedresource.com; Initial Catalog=RESTAURANT; User ID=your username; Password='your password';

像 :

<add name="RestaurantDB" connectionString="data source=RESTAURANT.db.9319451.hostedresource.com; 
Initial Catalog=RESTAURANT; User ID=your username; Password='your password'> 

<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;
provider=System.Data.SqlClient;provider connection string=&quot;Data Source=RESTAURANT.db.9319451.hostedresource.com; 
Initial Catalog=RESTAURANT; User ID=your username; Password='your password;
multipleactiveresultsets=True;App=EntityFramework&quot;" 
providerName="System.Data.EntityClient" />
于 2012-08-14T13:19:54.970 回答
0

我不知道如何处理这个问题,但我只是给你一个想法。试试看可能行得通首先像这样修改您的RestaurantDB连接字符串

<add name="RestaurantDB" connectionString="RESTAURANT.db.9319451.hostedresource.com;Initial Catalog=RESTAURANT; User ID=your username; Password='your password';"/>

餐厅这样的实体

<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=RESTAURANT.db.9319451.hostedresource.com;Initial Catalog=RESTAURANT;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

如果上述方法不起作用,那么还要在 RestaurantsEntities 连接字符串中添加用户 ID 和密码

于 2012-08-14T13:22:49.933 回答