且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

连接SQL Server数据库时出错

更新时间:2022-02-20 22:38:02

使用基于角色的会员资格

你需要安装SQL服务器,在你的机器上安装单独的服务器或部分Visual Studio。(SQLExpress是免费下载的。)



然后你需要创建一个数据库。空白一个。



现在你需要使用这个工具在新数据库中设置aspnet安全服务:



要启动aspnet_regsql.exe工具,请转到开始菜单并选择运行。在文本框中输入%WINDIR%\ Microsoft \\ net \Framework \v2.0.50727 \ aspnet_regsql.exe,然后单击确定。 ,您可以使用Windows资源管理器深入到相应的文件夹,然后双击aspnet_regsql.exe文件。这两种方法都会产生相同的结果。

来自: http://www.asp.net/web-forms/tutorials/security/membership/creating-the-membership-schema-in-sql-server-vb ^



在web.config中将连接字符串添加到这个新数据库。



更改web中的身份验证部分.config to mode =Forms。



在system.web部分内添加



To use role based membership
you need SQL server installed, either separate server or part of Visual Studio installation on your machine.( SQLExpress is free download).

Then you need to create a database. Blank one.

Now you need to setup the aspnet security services in the new database using the tool:

"To launch the aspnet_regsql.exe tool, go to the start menu and choose Run. Enter %WINDIR%\Microsoft.Net\Framework\v2.0.50727\aspnet_regsql.exe into the textbox and click OK. Alternatively, you can use Windows Explorer to drill down to the appropriate folder and double-click the aspnet_regsql.exe file. Either approach will net the same results."
From: http://www.asp.net/web-forms/tutorials/security/membership/creating-the-membership-schema-in-sql-server-vb^

Add the connection string to this new database in web.config.

Change the authentication section in web.config to mode="Forms".

Inside system.web section add

<rolemanager enabled="true">
      <providers>
        <clear />
        <add applicationname="/">
             connectionStringName="YourConnectionStringName"
             name="AspNetSqlRoleProvider"
             type="System.Web.Security.SqlRoleProvider" />
      </add></providers>
    </rolemanager>
    <membership userisonlinetimewindow="20">
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider">
             connectionStringName="YourConnectionStringName"
             type="System.Web.Security.SqlMembershipProvider"/>
      </add></providers>
    </membership>





现在尝试使用WSA工具。



Now try WSA Tool.