连接SQL Server数据库时出错 [英] Error in connecting SQL server database

查看:92
本文介绍了连接SQL Server数据库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建网站管理(WSA)工具时,我无法连接到sql server数据库。



我正在创建基于角色的用户成员资格应用程序。点击选项网站 - > asp.net配置,它带我去了WSA。当我点击安全标签时,发生了错误。



首页---安全---应用程序---提供商


您选择的数据存储存在问题。这可能是由无效的服务器名称或凭据或权限不足引起的。它也可能是由未启用角色管理器功能引起的。单击下面的按钮以重定向到您可以选择新数据存储的页面。



以下消息可能有助于诊断问题:无法连接到< b> SQL Server数据库。



当我点击选择数据存储时,此页面打开并显示如下...



使用此页面可以配置如何存储网站管理数据(如成员资格)。您可以为您的站点的所有管理数据使用单个提供程序,也可以为每个功能指定不同的提供程序。



您的应用程序当前配置为使用提供程序:AspNetSqlProvider



为所有站点管理数据选择一个提供商

为每个功能选择不同的提供商(高级)




当我点击第一个链接时,它显示为,



使用此页面选择存储站点管理数据的提供商。





提供者
AspNetSqlProvider 测试




事实是我不会将应用程序连接到数据库。



帮我解决这个问题。

When i was creating Web Site Administration (WSA) Tool, i was not able to connect to sql server database.

i was creating role based user membership application. clicking on option website->asp.net configuration, it took me to WSA. and when i clicked on security tab, error occured.

Home --- Security --- Application --- Provider

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

When i click on Choose Data Store this page opens and shows like this...

Use this page to configure how Web site management data such as membership is stored. You can use a single provider for all the management data for your site or you can specify a different provider for each feature.

Your application is currently configured to use the provider: AspNetSqlProvider

Select a single provider for all site management data
Select a different provider for each feature (advanced)


When i click on first link, it appears as,

Use this page to select a provider for storing site management data.


Provider
AspNetSqlProvider Test


The fact is that i con not connect application to the database.

Help me to resolve this.

推荐答案

使用基于角色的会员资格

你需要安装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.


这篇关于连接SQL Server数据库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆