简体   繁体   English

无法正确连接到ASP.NET应用程序中的SQL Server

[英]Can't correctly connect to SQL Server in ASP.NET application

I am trying to connect to a SQL Server database that already has all of the correct tables (among others) for using login credentials. 我正在尝试连接到SQL Server数据库,该数据库已经具有所有使用登录凭据的正确表(以及其他所有表)。

I have this code in my web.config file: 我的web.config文件中包含以下代码:

<connectionstrings>
   <add name="abcdCS" 
        providerName="System.Data.SqlClient" 
        connectionstring="Data Source=SERVERNAME;Initial Catalog=SCRUMAPIUI;Integrated Security=False;User ID=MYUSERNAME;Password=MYPASSWORD;MultipleActiveResultSets=True" />
</connectionstrings>

and when I open Website Administration Tool > Security, I get the following error: 当我打开网站管理工具>安全性时,出现以下错误:

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: Unrecognized configuration section add. 以下消息可能有助于诊断问题:添加了无法识别的配置部分。 (C:\\Documents and Settings\\tunnelld\\My Documents\\Visual Studio 2010\\WebSites\\ZSRBlank\\web.config line 7) (C:\\ Documents and Settings \\ tunnelld \\ My Documents \\ Visual Studio 2010 \\ WebSites \\ ZSRBlank \\ web.config第7行)

I have been trying to fix this for 5 hours. 我已经尝试修复了5个小时。 When I go to Website Administration Tool > Provider and test it always says: 当我转到“网站管理工具”>“提供程序”并进行测试时,它总是显示:

Successfully established a connection to the database. 成功建立与数据库的连接。

Please help! 请帮忙!

I have followed this tutorial exactly and get the same error: http://www.codeproject.com/Articles/89029/Using-SQL-Membership-with-ASP-NET-application 我完全按照本教程进行操作,并得到了相同的错误: http : //www.codeproject.com/Articles/89029/Using-SQL-Membership-with-ASP-NET-application

I think there's a slight typo here. 我认为这里有一个轻微的错字。 The property connectionstring in the add tag should actually be connectionString . add标记中的属性connectionstring实际上应该是connectionString Try this 尝试这个

<connectionstrings>
<add name="abcdCS" providerName="System.Data.SqlClient" connectionString="Data Source=SERVERNAME;Initial Catalog=SCRUMAPIUI;Integrated Security=False;User ID=MYUSERNAME;Password=MYPASSWORD;MultipleActiveResultSets=True" />
</connectionstrings>

If the server and database name are correct and the user credentials are correct it should work now. 如果服务器和数据库名称正确,并且用户凭据正确,则应该可以正常工作。 Also make sure that all your membership and role providers in your web config are now using your new connection string. 还要确保您的Web配置中的所有成员资格和角色提供程序现在都在使用新的连接字符串。 Should look something like this. 应该看起来像这样。

 <membership>
  <providers>
    <clear />
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="abcdCS" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers>
</membership>

Also check that the role manager has been enabled. 还要检查角色管理器是否已启用。

<roleManager enabled="true">

Hope this helps. 希望这可以帮助。 Good Luck... 祝好运...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM