0

Hi, i am trying to connect to a database(mysql), is this way right ?
I have added

using MySql.Data.MySqlClient;

I am getting a error on

Conni.Open();

, the error is saying: "Unable to connect to any of the specified MySQL hosts." Need help

string email = textBox1.Text;
            string password = textBox2.Text ;
            string password2 = textBox3.Text ;
            string fname = textBox4.Text;
            string lname = textBox5.Text;

            string CONFIG = "SERVER=localhost;" + "USERNAME=techozin;"+ "PASSWORD=waleed1984!;"+ "DATABASE=techozin_334900";
            MySqlConnection Conni = new MySqlConnection(CONFIG);
            MySqlCommand Querry = new MySqlCommand();
            Querry.Connection = Conni;
            Conni.Open();
            Querry.CommandText = "INSERT INTO mbmemer(email, password, firstname, lastname) VALUE(@email, @password, @firstname, @lastname)";
            Querry.Parameters.AddWithValue("@email", email);
            Querry.Parameters.AddWithValue("@password", password);
            Querry.Parameters.AddWithValue("@firstname", fname);
            Querry.Parameters.AddWithValue("@lastname", lname);
            Querry.ExecuteNonQuery();
            Conni.Close();
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by Momerath
0

The standard connection string for MySql looks like this:
Server=myServerAddress; Database=myDataBase; Uid=myUsername; Pwd=myPassword;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.