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

在VS.NET 2005 Beta 2


发现在 中默认的数据库是AspNetAccessProvider,Provider tab中可以选择AspNetSqlMembershipProvider ,但是test无法通过,显示错误是无法链接数据库,查找MSDN中的资料,发现配置链接信息在machine.config中设置,默认SQL Server的AspNetAccessProvider数据库是AspNetDB,而此时SQL Server 2005中并没有该数据库,因此出现了数据库无法链接的情况。自己添加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


安提示,最后数据库中将自动添加多个表、视图与存储过程如下:


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


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

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

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

posted on 2005-03-31 12:57 彭斌 阅读(...) 评论(...) 编辑 收藏

导航