简体   繁体   English

寻找Sql Server数据库连接的异常

[英]Exception looking for Sql server database connection

I have an ASP.NET web site that uses MVC. 我有一个使用MVC的ASP.NET网站。 This works great connecting to a SqlServer DB. 连接到SqlServer数据库非常有用。 I recently modified the code to connect to a MYSql DB and that works. 我最近修改了代码以连接到MYSql数据库,并且可以正常工作。 But when accessing some pages I get the following error, which says it is looking for a SQL Server connection. 但是在访问某些页面时,出现以下错误,该错误表示它正在寻找SQL Server连接。

This is the error: 这是错误:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. 建立与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. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

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. 错误的其余部分似乎表明它正在寻找SqlServer或Sql Server Express连接。 What is confusing is that everything has been changed to use MySql. 令人困惑的是,一切都已更改为使用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. 似乎它是仍在尝试使用MySql连接字符串访问Sql Server DB的库之一。

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. 问题是,当iis进入具有Web配置的Web站点的子目录中时,该Web配置包含上面代码snipit中列出的目录权限。 It wants to open up a connection to SQL Server or SQL Server Express to do the permission checks. 它希望打开与SQL Server或SQL Server Express的连接以进行权限检查。 Since I am using MySql for the connection string it gets confused and cannot handle it. 由于我使用MySql作为连接字符串,因此感到困惑,无法处理它。 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. 但这会导致问题,因为我正在iis中连接到其他实例上的SQL Server DB。 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. 我应用的解决方案是删除子文件夹web.config文件,并确保直接在每个页面上应用页面调试,这还是我要做的。 The Directory Permission check is just another level of security. 目录权限检查只是另一种安全级别。 But in typical MS fashion they come up short if not using their products. 但是以典型的MS方式,如果不使用其产品,它们就会变得很短。

so the ultimate solution is to not use MS identity mgt unless you write your own. 因此,最终的解决方案是除非您自己编写,否则不要使用MS Identity mgt。 This would also alleviate the obvious upgrade to identity mgt that MS seems to want to do with each new release. 这也将减轻MS似乎希望对每个新版本进行的身份管理的明显升级。

cheers and thanks for all the help. 欢呼,感谢所有帮助。 I hope I helped someone else with this issue. 我希望我可以帮助其他人解决这个问题。

At first you need to download theMySQLConnector. 首先,您需要下载MySQLConnector。 Then you can use the Entity Framework or the SqlCommand to connect to your database. 然后,您可以使用实体框架或SqlCommand连接到数据库。

More Information MySQL Connector for .NET MySQL Entity Framework Tutorial 更多信息.NET的MySQL连接器 MySQL实体框架教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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