作了一个WebPart的Demo运行的时候提示数据库连接错误,提示连接到SQL Express 错误,因为本机已经安装有SQL 2005找了半天不知道哪里修改WebPart的默认连接,Google了一下 找到相应的修改方法
1)运行 WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe 按照提示进行设置
2)在WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config中的
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">下添加
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnetdb;Persist Security Info=True;User ID=sa;Password=sa" providerName="System.Data.SqlClient" />
</connectionStrings>
再次运行就可以了

浙公网安备 33010602011771号