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 =@sid and STU_PWD =@pwd";
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);
}
}
In localhost it is working perfectly. Once I set my remote link instead of localhost. It's not connecting anymore. I am getting exception like Unable to connect to any of the specified MySQL hosts.
Try this one:
I hope this will solve your problem
Try it:-
MySqlConnection c = new MySqlConnection("server=10.54.3.208; database=agero; uid=root; pwd=root");
OR
string MyConString = "SERVER=10.54.3.208;" + "DATABASE=agero;" + "UID=root;" + "Pwd=root;";
refer this link for more information MySQL Connector
I hope it may help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.