'/'应用程序中的服务器错误[没有这样的主机已知]

时间:2013-07-12 09:09:13

标签: asp.net mysql

不知道此类主机

说明:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Net.Sockets.SocketException:不知道此类主机

来源错误:

Line 21:         MySqlConnection conn = new MySqlConnection(MyConStrings);
Line 22:         MySqlCommand cmd = new MySqlCommand("SELECT id ,name  FROM asd_table Where weekno      ='"+getWeek+"';", conn);
Line 23:         conn.Open(); //red highlight here

堆栈追踪:

   [SocketException (0x2af9): No such host is known]
   System.Net.Dns.GetAddrInfo(String name) +6603642
   System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6) +106
   System.Net.Dns.GetHostEntry(String hostNameOrAddress) +109
   MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder settings, Boolean unix) +64
   MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings) +38
   MySql.Data.MySqlClient.NativeDriver.Open() +55

[MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.]
   MySql.Data.MySqlClient.NativeDriver.Open() +151
   MySql.Data.MySqlClient.Driver.Open() +22
   MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +208
   MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +261
   MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +93
   MySql.Data.MySqlClient.MySqlPool.GetConnection() +65
   MySql.Data.MySqlClient.MySqlConnection.Open() +625
   play_db_mysql.Page_Load(Object sender, EventArgs e) in d:\hosting\folder1\html\web\website\asd_db_mysql.aspx.cs:23
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

一直困扰着这个,我将我的sql db托管在godaddy中,这是我在.cs文件中使用的连接字符串

String MyConStrings = "SERVER=serverurl;" +
    "DATABASE=dbname;" +
    "UID=username;" +
    "PASSWORD=passsword;";

任何帮助都会非常感激。

1 个答案:

答案 0 :(得分:2)

尝试查看是否可以从托管站点的Web服务器访问数据库serverurl。查看错误,似乎无法访问数据库服务器或DNS查找存在问题。

尝试通过Web服务器上的命令提示符ping数据库服务器。

对于可能的MySQL连接字符串,请参阅http://www.connectionstrings.com/mysql/