Connecting to MySQL Database C# -
i need connecting mysql server on web host. here code login button fails log me in.
private void btnlogin_click(object sender, eventargs e) { try { string strconnect = "server=localhost;database=cpr_users;uid=myusername;password=*******;"; mysqlconnection myconn = new mysqlconnection(strconnect); mysqlcommand selectcmd = new mysqlcommand("select * cpr_users.cpr_user_info username='" + txtusername.text + "' , password='" + txtpassword.text + "' ;", myconn); mysqldatareader myreader; myconn.open(); int count = 0; myreader = selectcmd.executereader(); while (myreader.read()) { count = count + 1; } if (count == 1) { this.close(); medicalform(); } else if (count > 1) { messagebox.show("theres 2 users username please contact your_name_here ...access denied"); } else messagebox.show("username or password not correct .. please try again!"); } catch (exception ex) { messagebox.show(ex.message); } }
i unsure of whether using wrong information connection
when use webhost's dedicated ip , log in given following error
authentication host '**ip address**' user 'myusername' using method 'mysql_native_password' failed message: access denied user 'myusername'@'myipaddress' (using password: yes)
try change server=localhost
server=127.0.0.1
if work verify hosts
file , set correct redirection ... else verify mysql prompt user & pass exists if exist verify correctly written in connection string
Comments
Post a Comment