WebPartManager,建立与服务器的连接时出错

解决方法如下:
第一种方法是禁用个性化服务,修改WebPartManager的属性:Personalization -> Enabled 为 False

如果需要使用个性化服务,就得使用下面这个办法:
1. 运行 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
按照提示安装数据库。

2. 在web.config文件的connectionStrings下加入一段连接字符串的配置:
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnetdb;Persist Security Info=True;User ID=sa;Password=123456"
providerName="System.Data.SqlClient" />

这段配置覆盖了默认的连接字符串,而使用自定义的。


The Solution: (3 simple steps)

1) Open your visual studio command prompt located in "Start Menu\Programs\Microsoft Visual Studio 2005\Visual Studio Tools\Visual Stuido 2005 Command Prompt" and type in aspnet_regsql.exe. This will launch a wizard so that you can either create a DB or add tables to an existing database for storing personalization infromation. Click Next, Next, then enter in your DBServer Name. Lets leave the DB as "default" for now, click next, next, finish. By leaving the db as default the tool will create a database named aspnetdb

2) Now we have a database so we will need a connection string to access it from our Personalization Provider in Step 3. The connection string will go into your web.config and it will be similar to the one show below:

<connectionStrings>

<remove name="LocalSqlServer" />

<add name="DBConn" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=aspnetdb;Data Source=DBServer" providerName="System.Data.SqlClient" />

</connectionStrings>


Note: The "remove" tag is used to inform Visual Studio that we will not be using SQL Express

3) The final step is to add our own personalization provider in the <system.web> section of the webConfig. The personalization provider will point to the store we created by using the connection string we provide (Dbconn).

<webParts>

<personalization defaultProvider="AspNetSqlPersonalizationProvider">

<providers>

<remove name="AspNetSqlPersonalizationProvider" />

<add name="AspNetSqlPersonalizationProvider"

type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider"

connectionStringName="DBConn"

applicationName="/" />

</providers>

</personalization>

</webParts>


是数据库连接问题,只要更改即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

和海风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值