在ASP.NET 2.0中配置 AspNetSqlMembershipProvider(AspNetSqlProvider )

在VS.NET 2005 Beta 2
vs%202005%20pd7.jpg

发现在 asp.net%20tool.jpg中默认的数据库是AspNetAccessProvider,Provider tab中可以选择AspNetSqlMembershipProvider ,但是test无法通过,显示错误是无法链接数据库,查找MSDN中的资料,发现配置链接信息在machine.config中设置,默认SQL Server的AspNetAccessProvider数据库是AspNetDB,而此时SQL Server 2005 SQL%202005.jpg中并没有该数据库,因此出现了数据库无法链接的情况。自己添加AspNetDB数据库后,再到 Web Site Administration Tool中test,这次通过,链接。正高兴进入security tab下进行设置时候,出现错误,提示某某存储过程没有找到。
记得在上几个版本的CTP中支持在 Web Site Administration Tool 中添加SQL 链接与数据库,而在该版本中并没有,不是否是安装 VS 2005时没有安装SQL 2005 Express(因为之前已经安装了 SQL 2005 Pro .Net FW与VS2005一致)。

继续在MSDN中找资料,发现如下文字:
Configuring the SQL Server Provider

If you want to use AspNetSqlProvider to store application feature data in a SQL Server database, you must first configure SQL Server by creating the appropriate database. ASP.NET includes a command-line utility named aspnet_regsql.exe that performs this task for you.

The aspnet_regsql.exe executable is located in the C:\WINDOWS\Microsoft.NET\Framework\versionNumber folder on your Web server. The aspnet_regsql.exe command is used to both create the SQL Server database and to add or remove options from an existing database.

You can run the aspnet_regsql.exe executable without any command-line arguments to run a wizard that will walk you through specifying connection information for SQL Server and installing or removing the database elements for all of the supported features. You can also run the aspnet_regsql.exe executable as a command-line utility to configure database elements for individual features.

To run the aspnet_regsql.exe wizard, run the aspnet_regsql.exe executable without any command-line arguments as shown in the following example.

C:\WINDOWS\Microsoft.NET\Framework\versionNumber\aspnet_regsql.exe

To view help for additional options available with the aspnet_regsql.exe utility, use the /? option.


随后启动aspnet_regsql.exe
%7BF52F98E8-53BC-4F82-AA60-1A396DFEC8F2%7D0.jpg

安提示,最后数据库中将自动添加多个表、视图与存储过程如下:
%7B2D7803B9-EA30-4A8B-B079-B7BE5669A0FE%7D0.jpg

自此,AspNetSqlProvider配置完毕
可以正常连接数据库与测试


不知道是我愚笨还是beta版本的问题,设置起来的确麻烦,因此写下来免得遇到同类问题的朋友浪费之间

另:如何配置SQLEXPRESS的 AspNetSqlMembershipProvider 链接,就是实现想access那样可以安相对目录配置mdf数据库,我配置没有成功,如果配置成功的请指教
我的链接语句如下:Data Source=.\SQLEXPRESS;AttachDbFilename=~\App_Data\AspnetDB.mdf;Integrated Security=True

链接数据库没有问题,但是无法实现AspNetSqlMembershipProvider

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值