Question: This is the error I'm getting:

[enter image description here](https://i.stack.imgur.com/mwDka.png)

with this code:

```
private void button1_Click_1(object sender, EventArgs e)
{
    if (txtID.Text == "" || txtName.Text == "" || txtMobileNo.Text == "")
    {
        MessageBox.Show("Please Enter all of your detail.", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
    else
    {
        string query = "INSERT INTO tablemm (id,Name,MobileNo) VALUES ('" + txtID.Text + "','" + txtName.Text + "','" + txtMobileNo.Text + "')";

        OpenConnection();

        MySqlCommand ObjCommand = new MySqlCommand(query, ObjConnection);
        ObjCommand.ExecuteNonQuery();

        this.CloseConnection();
    }
}

```

Answer: 
You have probably forgotten to call `Open`

```
MySqlCommand myCommand = new MySqlCommand(myExecuteQuery, myConnection);
myCommand.Connection.Open();  // wallah 
myCommand.ExecuteNonQuery();
myConnection.Close();

```

Also use a `using` statement where possible, 

**Disclaimer**: This is only for demonstration purposes and I can't be held responsible for the people you maim and otherwise hurt with this code
I believe that your `INSERT` statement should be *after* you open your connection with the database and right before you close it.