Hi everyone

I am writing a program using c# and connecting to microsoft access. I get this Data type mismatch in criteria exception and cant find the problem. Can anyone help me please?

My Code:
>

  try
> {
>        myCommand = new OleDbCommand();
>        myCommand.CommandType = CommandType.Text;
>        myCommand.CommandText = "INSERT INTO Customers(Name, Adress1, Adress2, Adress3, PostCode)" +
>                                "VALUES('" + tbxNameCust.Text + "','" + tbxAdresCust.Text + "','" +
>                                tbxAdress2.Text + "','" + tbxAdress3.Text + "','" + tbxPosCust.Text + "')";
>        myCommand.Connection = myConnection;
>        myConnection.Open();
>        myCommand.ExecuteNonQuery();
> 
>         MessageBox.Show("Customer successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
>  }
>  catch (Exception e3)
>  {
>        MessageBox.Show("Error saving new Customer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
>  }
>  finally
>  {
>       myConnection.Close();
>  }

Where is the error in code, have tried to run your sql code in access?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.