protected void Button1_Click(object sender, EventArgs e)
{
try
{
string MyConString = "SERVER=http://10.54.3.208:8080/Ager/person;" + "DATABASE=agero;" + "UID=root;" + "PASSWORD=root;";
MySqlConnection con = new MySqlConnection(MyConString);
//MySqlConnection command = con.CreateCommand();
con.Open();
string s = "select * from boopathi where STU_ID [email protected] and STU_PWD [email protected]";
MySqlCommand cmd = new MySqlCommand(s, con);
cmd.Parameters.AddWithValue("@sid", TextBox1.Text.ToString());
cmd.Parameters.AddWithValue("@pwd", TextBox2.Text.ToString());
cmd.ExecuteNonQuery();
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr.HasRows == true)
{
Server.Transfer("WebForm1.aspx");
}
}
//close connection
con.Close();
}
catch (Exception ex)
{
Response.Write("An error occured: " + ex.Message);
}
}
在本地主机上它工作的很完美。一旦我设置了远程链接而不是本地主机。它不再连接。我越来越喜欢Unable to connect to any of the specified MySQL hosts.
如何使用mysql在asp.net中连接远程数据库?
我猜想端口3306被阻塞在你的网络路径中。什么是提出的例外? – rene
我得到“无法连接到任何指定的MySQL主机”。 – user2995210
将其编辑到您的问题中,这非常相关。你已经检查过端口3306是否被阻塞? – rene