2

我有我的实时数据库中存在的所有表单身份验证数据库表的完整副本,我可以看到数据在那里,我可以在我的应用程序上连接和查看单独的数据......但是当我尝试使用我的网站登录时,我得到

建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:SQL 网络接口,错误:26 - 错误定位服务器/指定的实例)

然后潜在的错误似乎是它正在尝试创建一组新的用户身份验证表,因为它无法连接到我的 MYSQL DB。我这么说是因为堆栈跟踪错误:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5103182
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +260
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +389
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject, Boolean withFailover) +197
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +963
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +316
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +5119675
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +31
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +76
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.SqlClient.SqlConnection.Open() +125
   System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +82

**[HttpException (0x80004005): Unable to connect to SQL Server database.]**
   System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +137
   System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +94
   System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +27
   System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +395

我的 Web.config 文件看起来像

<remove name="LocalMySqlServer" />


<add name="mydbEntities" connectionString="metadata=res://*/DataEntity.csdl|res://*/DataEntity.ssdl|res://*/DataEntity.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=servername;User Id=id;password=password;Persist Security Info=True;database=mydb&quot;" providerName="System.Data.EntityClient" />
<add name="MySqlMembershipConnection" connectionString="server=localhost; user id=id; password=password; persist security info=true; database=mydb;" providerName="MySql.Data.MySqlClient"/>

<roleManager enabled="true" />
<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear />
    <add name="MySqlMembershipProvider" 
         type="MySql.Web.Security.MySQLMembershipProvider, 
         MySql.Web, 
         Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" 
         autogenerateschema="true" 
         connectionStringName="MySqlMembershipConnection" 
         enablePasswordRetrieval="false" 
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         passwordFormat="Hashed" 
         maxInvalidPasswordAttempts="5" 
         minRequiredPasswordLength="6" 
         minRequiredNonalphanumericCharacters="0" 
         passwordAttemptWindow="10" 
         passwordStrengthRegularExpression="" 
         applicationName="/" />
  </providers>
</membership>

我不确定为什么它找不到我的 MYSQL 数据库,或者是什么事件链导致登录过程失败。

4

1 回答 1

1

这个问题归结为我没有指定完整的成员资格、配置文件和角色管理器选项。一旦我填写了这些并将我的应用程序定向到我的 MySQL 数据库,它就会停止尝试创建自己的数据库来处理这些功能。下面是我的 web.config 文件需要包含的 3 个部分的示例……希望这可以减轻其他人的挫败感,我得说 Arvxie 支持在这个问题上没有帮助。

<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear />
    <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="false" connectionStringName="MySqlMembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
  </providers>
</membership>
<profile>
  <providers>
    <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="MySqlMembershipConnection" applicationName="/" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
  <providers>
    <add connectionStringName="MySqlMembershipConnection" applicationName="/" name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  </providers>
</roleManager>
于 2012-06-13T14:23:50.293 回答