Question

I have the full copy of all the form authentication DB tables existing on my live DB, I can see the data is there, and I can connect and view separate data on my app...but when I try and Login with my site I get a

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)

and then the underlying error seems to be that it is trying to create a set of new user authentication tables because it cant' connect to my MYSQL DB. I am saying this due to the stack trace error of:

[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

My Web.config file looks like

<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>

I'm not sure why it is failing to find my MYSQL DB or what chain of events is causing the login process to fail.

Was it helpful?

Solution

This problem came down to the fact that I had not designated the full set of membership, profile, and roleManager options. Once I filled in these and directed my app to my MySQL DB it stopped trying to create it's own DB to handle these functions. Below is an example of the 3 sections my web.config file needed to contain... hopefully this saves someone else the frustration I had, and I gotta say Arvxie support was no help on this issue.

<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top