Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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......
Posted
Updated 18-Jun-13 20:09pm
v2

You don't use a ? for parameters, you use @. Try that and see what happens.
 
Share this answer
 
put "localhost" instead of "localhost:8086"
 
Share this answer
 
Change ur code:
"Server=loclhost:8086;"


with this...
"Server=localhost;"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900