急哭了!配置Web.Config时出现无法连接到 SQL Server 数据库的问题!!! http://www.cnblogs.com/tonyqus/archive/2005/12/02/288886.html看看这个 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnblogs.com/tonyqus/archive/2005/12/18/userprofilev2.html#userprofiles_topic8 在命令行上通过aspnet_resql可以在你指定的数据库上建立用于Membership、Profile、Role等的表。假设你建在如下的color=#003366]你的数据库[/color]上。那么剩下的事就是让自定义的profile也存到这个数据库上。也就是在profile里配置connctionStringName为你的连接字符串" 。//web.config<connectionStrings> <add name="你的连接字符串" connectionString="Data Source=localhost;Initial Catalog=你的数据库;Integrated Security=True" providerName="System.Data.SqlClient" /></connectionStrings>...<profile enabled="true" defaultProvider="AspNetSqlProfileProvider" inherits="" automaticSaveEnabled="true"> <providers> <clear /> <add connectionStringName="你的连接字符串" applicationName="/" name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> <properties> <clear /> <add name="MyNewProperty" type="System.String"/> </properties></profile> sorry,应该是aspnet_regsql命令。 你换一种方式好了web.config:<?xml version="1.0"?><!-- 注意: 除了手动编辑此文件以外,您还可以使用 Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的 “网站”->“Asp.Net 配置”选项。 设置和注释的完整列表在 machine.config.comments 中,该文件通常位于 \Windows\Microsoft.Net\Framework\v2.x\Config 中--><configuration> <connectionStrings> <appSettings> <add key="ConnectionString" value="server=127.0.0.1;uid=sa;pwd=;database=mydatabase" /> </appSettings> </connectionStrings> <system.web> <!-- 设置 compilation debug="true" 将调试符号插入 已编译的页面中。但由于这会 影响性能,因此只在开发过程中将此值 设置为 true。 --> <compilation debug="true"/> <!-- 通过 <authentication> 节可以配置 ASP.NET 使用的 安全身份验证模式, 以标识传入的用户。 --> <authentication mode="Windows"/> <!-- 如果在执行请求的过程中出现未处理的错误, 则通过 <customErrors> 节可以配置相应的处理步骤。具体说来, 开发人员通过该节可以配置 要显示的 html 错误页 以代替错误堆栈跟踪。 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> </system.web></configuration>**********************************在代码(.cs)里面引用:using System.Data;using System.Data.SqlClient;...string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"])SqlConnection myconn = new SqlConnection(settings); myconn.Open();....... 就用yangtzeu的方法,我都这么用 参考:http://download.csdn.net/source/321684 ********************************** 在代码(.cs)里面引用: using System.Data; using System.Data.SqlClient; ... string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]) ;SqlConnection myconn = new SqlConnection(settings); myconn.Open(); ....... 不好意思,有点小问题 ,";"给疏忽了 从6楼yangtzeu 学到了一些东西,很有用,先记下来了。但总的来看问题还是没有解决.2楼Sandy945的方法不可以,也就是帖子中提到的第4个错误:运行SDK下的aspnet_regsql启用向导配置,在出现选择服务器和数据库时 未能查询Sql Server中的数据库名称的列表。 在建立与服务器的连接时出错。insus的视频也用不上,我会用asp.net或C# + SQL Server写程序,而且我的机器也可以执行asp.net+sqlserver的项目,在vs2005的服务器资源管理器中也可以添加数据库,修改表等。后来把机器名改成my-PC\SQLEXPRESS可以了,现在在SQL Server Management Studio Express中可以看到aspnetdb数据库已经建立好了。但是在ASP.NET 配置-〉提供程序-〉AspNetSqlProvider 测试仍有问题,出现同样的错误。也有人告诉我machine.config和web.config里面看看session state是不是inproc方式,但是里面搜索没有类似的设置。也有人告诉我express 要设置不少东西~ 比如说 允许tcp/ip连接咯...开启sa帐号咯... sa帐号已经开启了,但是我不知道他说的允许tcp/ip连接是指什么,没安装天网等网络防火墙。 方法记在了我的博客里,现在结贴:http://www.cnblogs.com/lqb/archive/2008/02/17/1071650.html 为什么我的 显示无法识别的元素“appSettings”。呢? upupupupupupupupupupupupupupupupupupupupup 返回一个表中所有的字段 点击button,在后台赋值后,新开窗口 Ajax 输出 图片(二进制流)问题 我用iis运行网页时出现如下错误,请问各位高手,要在哪里改才能不出错!!!!! 弹出层方法替换window.showModalDialog 数据库三张表有主外键关系怎么删除 IIS的问题? 点击HyperLinkColumn打开新窗口,新打开的窗口没有标题栏、工具栏、菜单。谢谢 asp.net中的验证控件冲突问题? 中间表类设计 gridview自定义分页无法触发PageIndexChanging事件 ErrorPage.aspx?aspxerrorpath=/Login.aspx
假设你建在如下的color=#003366]你的数据库[/color]上。那么剩下的事就是让自定义的profile也存到这个数据库上。也就是在profile里配置connctionStringName为你的连接字符串" 。//web.config
<connectionStrings>
<add name="你的连接字符串" connectionString="Data Source=localhost;Initial Catalog=你的数据库;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>...<profile enabled="true" defaultProvider="AspNetSqlProfileProvider" inherits="" automaticSaveEnabled="true">
<providers>
<clear />
<add connectionStringName="你的连接字符串" applicationName="/" name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
<properties>
<clear />
<add name="MyNewProperty" type="System.String"/>
</properties>
</profile>
web.config:<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件以外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
<connectionStrings>
<appSettings>
<add key="ConnectionString" value="server=127.0.0.1;uid=sa;pwd=;database=mydatabase" />
</appSettings> </connectionStrings>
<system.web>
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true"/>
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,
以标识传入的用户。
-->
<authentication mode="Windows"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>**********************************
在代码(.cs)里面引用:
using System.Data;
using System.Data.SqlClient;
...
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"])
SqlConnection myconn = new SqlConnection(settings);
myconn.Open();.......
http://download.csdn.net/source/321684
在代码(.cs)里面引用:
using System.Data;
using System.Data.SqlClient;
...
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]) ;
SqlConnection myconn = new SqlConnection(settings);
myconn.Open(); ....... 不好意思,有点小问题 ,";"给疏忽了
运行SDK下的aspnet_regsql启用向导配置,在出现选择服务器和数据库时
未能查询Sql Server中的数据库名称的列表。
在建立与服务器的连接时出错。insus的视频也用不上,我会用asp.net或C# + SQL Server写程序,而且我的机器也可以执行asp.net+sqlserver的项目,在vs2005的服务器资源管理器中也可以添加数据库,修改表等。后来把机器名改成my-PC\SQLEXPRESS可以了,现在在SQL Server Management Studio Express中可以看到aspnetdb数据库已经建立好了。但是在ASP.NET 配置-〉提供程序-〉AspNetSqlProvider 测试仍有问题,出现同样的错误。也有人告诉我machine.config和web.config里面看看session state是不是inproc方式,但是里面搜索没有类似的设置。也有人告诉我express 要设置不少东西~ 比如说 允许tcp/ip连接咯...开启sa帐号咯...
sa帐号已经开启了,但是我不知道他说的允许tcp/ip连接是指什么,没安装天网等网络防火墙。
http://www.cnblogs.com/lqb/archive/2008/02/17/1071650.html