im having trouble with this oledb commands im just a starter using this commands why can i not add to a microsft access is my insert declaration wrong can i give my code just for you to check it if something is wrong?

Nothing we can do without the code.

Exactly, provide us a code that causes issues to you. Then we can show (explain) what is or might be wrong with it.

Sorry, not going to dig through your code to find the problem. Post the method that is having an issue, the issue it's having and indicate the line that is having the problem.

sori im just new here i dont have eror in my code only my problem is i cant add to microsoft access and i dont know why w8 post my code

 public bool SaveProduct(Product product, bool update)
        {
            try
            {
                OleDbCommand cmd;


                if (update)
                {

                    cmd = new OleDbCommand(
                      "UPDATE Products SET prodID = ?, prodName = ?, unitPrice = ?, qtyOnHand = ?", conn);
                }
                else
               {
                    cmd = new OleDbCommand(
                       "INSERT INTO Products(prodID, [prodName], [unitPrice], [qtyOnHand])" + " VALUES (@prodID, @prodName, @unitPrice, @qtyOnHand)", conn);
                }

                cmd.Parameters.Add("prodID", OleDbType.VarChar).Value = product.ID;
                cmd.Parameters.Add("prodName", OleDbType.VarChar).Value = product.Name;
                cmd.Parameters.Add("unitPrice", OleDbType.Decimal).Value = product.UnitPrice;
                cmd.Parameters.Add("qtyOnHand", OleDbType.Integer).Value = product.QtyOnHand;


                cmd.ExecuteNonQuery();
                return true;
            }
            catch //(Exception ex)
            {
               // MessageBox.Show(ex.Message, "Error. Try Again.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }

Try changing the insert statement to
INSERT INTO Products(prodID, ProdName, UnitPrice, QtyOnHand) VALUES (?, ?, ?, ?)

sori but i cant still add to a microsoft access when i tried this code the one i added did not show in the table in microsoft 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.