private void button1_Click(object sender, EventArgs e)
{
try
{
MySqlConnection con = new MySqlConnection("Server=loclhost:8086;Database=test1;Uid=root;Pwd=");
con.Open();
string commandText = "INSERT INTO spt_proposal(Name,Address,MobileNo)" + " VALUES(?Name, ?Address, ?MobileNo)";
MySqlCommand command = new MySqlCommand(commandText, con);
command = new MySqlCommand(commandText, con);
command.Parameters.Add("?Name", MySqlDbType.VarChar, 20).Value = txt_Name.Text;
command.Parameters.Add("?Address", MySqlDbType.VarChar, 100).Value = txt_addr.Text;
command.Parameters.Add("?MobileNo", MySqlDbType.VarChar, 100).Value = txt_mobi.Text;
command.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
i got the below error
Call to GetHostEntry failed after 00:00:02.3326142 while querying for hostname 'localhost:8086': SocketErrorCode=HostNotFound, ErrorCode=11001, NativeErrorCode=11001.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at TestMySql.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\Desktop\11-05-13\CSharp_ASPMessageBox\TestMySql\TestMySql\Form1.cs:line 27
please help me.....
Thanks in advance......