0

I tried following this: ASP.NET Membership/Role providers for MySQL? but I get a SqlException that says "Error locating Server/Instance Specified".

Got any ideas on what I could do?

Error Image

Web.config membership:

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

ConnectionString:

<connectionStrings>
<add name="localhoststr" connectionString="Data Source=localhost;port=3306;Initial Catalog=aspnet;User Id=test;password=test"/>

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Orbit
  • 31
  • 6
  • That looks like a Sql Server connection string. We need to know what driver you're using to know for sure, but the use of "Sql Server" in the error message seems to bear this out. Make sure you're using `MySql` ADO.Net objects rather than Sql Server objects. – Joel Coehoorn Oct 14 '19 at 14:50
  • You should probably specify the providerName on your connection string, in addition to using the correct format for a MySQL database. Check out connectionstrings.com – mason Oct 14 '19 at 15:28
  • @mason Even using this connectionString SERVER=localhost;DATABASE=aspnet;UID=test;PASSWORD=test nothing changes – Orbit Oct 14 '19 at 17:05
  • Did you update the provider name, as I suggested? The exception type indicates it's using code designed for MS SQL Server instead of MySQL. So you need to find out why, and the providerName could be it. – mason Oct 14 '19 at 17:07
  • @JoelCoehoorn As you can see here the error is coming from the Roles https://imgur.com/UdQx9QF – Orbit Oct 14 '19 at 17:13
  • @mason Do you mean the defaultProvider in Web.config? That is set to "MySqlMembershipProvider". – Orbit Oct 14 '19 at 17:15
  • No, I don't. Each connection string has a property providerName. You aren't specifying what it is, so it's probably reverting to System.Data.SqlClient. – mason Oct 14 '19 at 17:17
  • @mason Ah, I see. I tried setting it to "MySql.Data.MySqlClient" without knowing if that's correct but that did not seem to fix my issue. – Orbit Oct 14 '19 at 17:19
  • @Orbit That's just the first code to run to encounter an error. Look at the error message, not the code that throws it. In this case, you have a .config file using `MySqlMembershipProvider`, which is for the **MySql** engine, and C# code trying to use the `System.Data.SqlClient` namespace, which is the ADO.Net provider for the **Sql Server** database. MySql and Sql Server are two very different products. You can't mix and match them like that. – Joel Coehoorn Oct 14 '19 at 17:20
  • What is the stack trace on your error? You left that out of your question. Please post it as text (not an image). – mason Oct 14 '19 at 17:21
  • @JoelCoehoorn I know I can't mux Sql and MySql that's why im trying to make Roles work with MySql so I can use only that. – Orbit Oct 15 '19 at 21:49

1 Answers1

0

I had a similar issue and mine ended up being linked to the port being used.

refer to https://blogs.msdn.microsoft.com/sql_protocols/2007/05/13/sql-network-interfaces-error-26-error-locating-serverinstance-specified/

Ben Hart
  • 15
  • 3