I am making a simple registration form using Xamarin.forms which is connected to a MySQL Database. I’ve watched this video as a tutorial but it keeps showing me the same error, Unable to Connect to any of the Specified MySQL Hosts.
private void RegistrationSubmit_Clicked(object sender, EventArgs e)
{
string conString = "Server=localhost; Uid=root; Pwd=ahsan; Database=geolocatordb";
using(MySqlConnection con = new MySqlConnection(conString))
{
try
{
con.Open();
string query = $"INSERT INTO usercreds(user_name, user_email) VALUES ({Username.Text}, {Email.Text})";
MySqlCommand cmd = new MySqlCommand(query, con);
cmd.ExecuteNonQuery();
RegistrationSubmit.Text = "OK";
}
catch(Exception ex)
{
RegistrationSubmit.Text=ex.Message;
}
}
}
Searching Online, i’ve found that there is some problem in the connection string and i’ve tried changing the connection string but nothing seems to work.




