0

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();
>  }
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by Michael27
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.