Data Type Mismatch In Inserting a Numeric Value

Hi guys, I am using C# windows based GUI and MS-Access as my database. Unfortunately, I cannot insert a record with a numeric value, this means that one of my field is a number data type. Below is my code;

strItemCode = lvProducts.Items[i].SubItems[0].Text.Trim();
                    iQty = int.Parse(lvProducts.Items[i].SubItems[2].Text);
                    cmAdjustedItems.CommandText = "INSERT INTO tblAdjustedItems VALUES(@itemcode, @adjustmentid, @qty)";
                    cmAdjustedItems.Parameters.AddWithValue("@itemcode", strItemCode);
                    cmAdjustedItems.Parameters.AddWithValue("@adjustmentid", strAdjustmentID);
                    cmAdjustedItems.Parameters.AddWithValue("@qty", iQty);

All the variables in my code were properly declared. Please give an idea on how am I going to solved this issue.

The error is Data Type Mismatch.

You can set a break point and then step into your code and see exactly what value is being passed and then double check it with the data type of your database field

Actually, I am confuse because the values being passed to each of my parameter in my query are correct, this also mean that the value in my variable iQty is a number.

How about if you try not to add the parameters with value, instead you first define the parameters including the db data type, and then adding the values afterwards.

Are any errors thrown?