简体   繁体   中英

Exception looking for Sql server database connection

I have an ASP.NET web site that uses MVC. This works great connecting to a SqlServer DB. I recently modified the code to connect to a MYSql DB and that works. But when accessing some pages I get the following error, which says it is looking for a SQL Server connection.

This is the error:

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)

Has anyone seen this before? I have been dealing with this for a couple of days and have not found any relevant information on this topic. The rest of the error seems to indicate that it is looking for a SqlServer or a Sql Server Express connection. What is confusing is that everything has been changed to use MySql. It seems like it is one of the libraries that is still trying to access a Sql Server DB with the MySql connection string.

Thanks for any help you can provide.

-- update. the problem is that when iis goes into a sub directory in the web site with a web config that includes directory permissions as listed above in the code snipit. It wants to open up a connection to SQL Server or SQL Server Express to do the permission checks. Since I am using MySql for the connection string it gets confused and cannot handle it. It appears the solution would be to alter the machine config. but that would cause problems since I am connecting to SQL Server DB's on other instances in iis. the solution I applied is to remove the sub folder web.config files and make sure that page commissioning is applied on each page directly, which is what I do anyway. The Directory Permission check is just another level of security. But in typical MS fashion they come up short if not using their products.

so the ultimate solution is to not use MS identity mgt unless you write your own. This would also alleviate the obvious upgrade to identity mgt that MS seems to want to do with each new release.

cheers and thanks for all the help. I hope I helped someone else with this issue.

At first you need to download theMySQLConnector. Then you can use the Entity Framework or the SqlCommand to connect to your database.

More Information MySQL Connector for .NET MySQL Entity Framework Tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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