Hi Folks
Iam trying to insert values into my access table using c# and iam at my wits end
My Access table has the following fields
Country State Curr VAT and Exchange
I have made them all as text for ease of use in the access database

this is my attached code, can you let me know where iam wrong as i get this weird error
Ole db error Datatype mismatch configaration

//Source Code 
private void CountrySaveButton_Click(object sender, EventArgs e)
        {
            int t = 0;
            String Country = "";
            String State = "";
            String currency = "";
            string exchange = "";
            string VAT = "";
            string conString =
                 @"Provider=Microsoft.JET.OLEDB.4.0;"
               + @"data source=E:\SorenProject\MedicalDataBase.mdb";
            OleDbConnection conn = new OleDbConnection(conString);
            int flag = 0;
            // create an open the connection          
            try
            {

                conn.Open();
            }
            catch (Exception eqw)
            {
                Console.WriteLine("error");

            }

 String myAddQuery = "INSERT INTO Country ([Country], [State], [Curr], [VAT], [Exchange]) VALUES('{0}', '{1}', '{2}', '{3}','{4}')";
               myAddQuery = string.Format(myAddQuery, Country, State, currency, VAT, exchange);


                try
                {



                    OleDbCommand myCommand = new OleDbCommand(myAddQuery, conn);

                   // conn.Open();

                    t = myCommand.ExecuteNonQuery();

                }

                catch (OleDbException ex)
                {

                    MessageBox.Show("OleDB Error: " + ex.Message);





             }   



                }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.