Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error connecting to MS SQL server

I have the following connection string in a web.config file to connect to MS Sql database.

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Server=developer\SqlExpress;Integrated Security=True;Database=mydb" providerName="System.Data.SqlClient"/>

I have MS SQL server and MySQL server on the same machine. When I try to run the application I get the following error in the line 285 in the machine.config file.

Error:

Parser Error Message: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'localhost' (using password: NO)

<add name="MySqlSiteMapProvider"  type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />

The error is related to mySQL but I am trying to connect MS SQL.

How can I solve the problem?

like image 393
Abdul Gafoor M Avatar asked Nov 30 '22 17:11

Abdul Gafoor M


2 Answers

This problem occurs when you install Mysql with MySql Connector Net. When Mysql Connector Net installed your computer, it configures your "machine.config" according to your .net version.

There are couple of ways to solve it.

1) You can add <clear /> tag in your provider. "Machine.config" overrides your custom provider, so to disable this we add <clear /> tag in your project web.config.

 <siteMap defaultProvider="SitefinitySiteMap">
  <providers>
    <!-- This line added. -->
    <clear />
    <add name="SitefinitySiteMap" type="Telerik.Sitefinity.Web.SitefinitySiteMap, Telerik.Sitefinity" />
  </providers>
</siteMap>

2) Second way is little bit tricky and if you use Mysql with .net, this might cause error on your projects.

Firstly, you need to find location of "machine.config". You can get more information here: https://stackoverflow.com/a/2325492/3801977

In my case, location is:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config

Open your "machine.config", and find following line and remove it:

<siteMap>
  <providers>
    <add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=8.0.13.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
  </providers>
</siteMap>
like image 164
Yigit Yuksel Avatar answered Dec 04 '22 08:12

Yigit Yuksel


"Remove" the MySqlSiteMapProvider provider in your web.config like this:

<siteMap>
  <providers>
    <remove name="MySqlSiteMapProvider" /> <!-- add this line -->
  </providers>
</siteMap>
like image 21
Sam Zakhezin Avatar answered Dec 04 '22 08:12

Sam Zakhezin