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