无法从ASP.NET连接到MySQL数据库 [英] Unable to connect to MySQL database from ASP.NET

查看:532
本文介绍了无法从ASP.NET连接到MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与MySQL数据库的连接有问题。我MySQLData.dll。我的连接字符串样子的:

 字符串SCON =服务器= mysql51-105.perso;数据​​库= adamlato; UID =名字;密码=通;
 

我有OVH的服务器。我认为,服务器名称是一个问题。我收到以下错误:

  MySql.Data.MySqlClient.MySqlException(0X80004005):无法连接到任何指定的MySQL主机。
 ---> System.Net.Sockets.SocketException(0X80004005):Żądananazwa笑话prawidłowa,强麦丹麦żądanegotypu聂zostałyznalezione
     在System.Net.Dns.GetAddrInfo(字符串名称)
     在System.Net.Dns.InternalGetHostByName(字符串主机名,布尔includeIPv6)
     在System.Net.Dns.GetHostEntry(字符串hostNameOrAddress)
     在MySql.Data.Common.MyNetworkStream.GetHostEntry(字符串主机名)
     在MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder设置,布尔UNIX)
     在MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder设置)
     在MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder设置)
     在MySql.Data.MySqlClient.NativeDriver.Open()
     在MySql.Data.MySqlClient.NativeDriver.Open()
     在MySql.Data.MySqlClient.Driver.Open()
     在MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder设置)
     在MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
     在MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
     在MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
     在MySql.Data.MySqlClient.MySqlPool.GetConnection()
     在MySql.Data.MySqlClient.MySqlConnection.Open()
     在System.Data.Common.DbDataAdapter.FillInternal(数据集的数据集,数据表[]的数据表,的Int32 startRecord用于,的Int32最大记录,字符串srcTable要,IDbCommand的命令的CommandBehavior行为)
     在System.Data.Common.DbDataAdapter.Fill(数据集数据集的Int32 startRecord用于,的Int32最大记录,字符串srcTable要,IDbCommand的命令的CommandBehavior行为)
     在System.Data.Common.DbDataAdapter.Fill(数据集的数据集,字符串srcTable要)
     在_Default.Page_Load(对象发件人,EventArgs的)
 在C:\用户\ ADAM \文档\ Visual Studio的2013 \网站已\ WEBSITE2 \ Default.aspx.cs:行20
 

解决方案
  • 添加的ProviderName = MySql.Data.MySqlClient 来连接字符串
  • 添加引用 MySQL.Data 到项目

其他故障排除,确保有关以下内容:

  1. 在数据库启动并接受查询。
  2. 你能连接到数据库的本地数据库服务器上?
  3. 请您在Web服务器和数据库服务器之间的防火墙或者是他们在同一台机器上?

更多帮助以下参考: HTTP://www.$c$cproject.com/Articles / 43438 /连接-C到MySQL

I have got a problem with connection with MySQL Database. I got MySQLData.dll. My connection string looks like that:

String sCON = "Server=mysql51-105.perso; Database=adamlato;  UID=name; Password=pass";

I have got OVH server. I think server name is a problem. I'm getting the following error:

MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
 ---> System.Net.Sockets.SocketException (0x80004005): Żądana nazwa jest prawidłowa, ale dane żądanego typu nie zostały znalezione
     at System.Net.Dns.GetAddrInfo(String name)
     at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
     at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
     at MySql.Data.Common.MyNetworkStream.GetHostEntry(String hostname)
     at MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder settings, Boolean unix)
     at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
     at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
     at MySql.Data.MySqlClient.NativeDriver.Open()
     at MySql.Data.MySqlClient.NativeDriver.Open()
     at MySql.Data.MySqlClient.Driver.Open()
     at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
     at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
     at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
     at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
     at MySql.Data.MySqlClient.MySqlPool.GetConnection()
     at MySql.Data.MySqlClient.MySqlConnection.Open()
     at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
     at _Default.Page_Load(Object sender, EventArgs e)
 in c:\Users\Adam\Documents\Visual Studio 2013\WebSites\WebSite2\Default.aspx.cs:line 20

解决方案

  • Add ProviderName=MySql.Data.MySqlClient to your connection string
  • Add reference MySQL.Data to your project

Additional troubleshooting, Make sure about the following:

  1. database started and accepting queries.
  2. Can you connect to the database locally on the database server?
  3. Do you have a firewall between the web server and the database server or are they on the same machine?

More Help on the following reference: http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL

这篇关于无法从ASP.NET连接到MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆