c# - How to connect remote database in asp.net using mysql? -
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 * boopathi stu_id =@sid , 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 working perfectly. once set remote link instead of localhost. it's not connecting anymore. getting exception unable connect of specified mysql hosts.
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 link more information mysql connector
i hope may you.
Comments
Post a Comment