0

I've got this error: Additional information: Data type mismatch in criteria expression.

I don't know why.. I want to use split text in a textbox and insert the splitted texts to ms access.
Here is my code:

string[] splittedText1 = textBox2.Text.Split(' ');
            string[] splittedText2 = textBox1.Text.Split(' ');
            string[] splittedText3 = textBox3.Text.Split(' ');

            string vsql = "Insert into [sales] ([productname], productquantity, productprice) VALUES (?,?,?)";
            OleDbCommand CmdSql = new OleDbCommand(vsql, vcon);
            CmdSql.Connection = vcon;

            CmdSql.Parameters.AddWithValue("@productname", OleDbType.VarWChar);
            CmdSql.Parameters.AddWithValue("@productquantity", OleDbType.UnsignedTinyInt);
            CmdSql.Parameters.AddWithValue("@productprice", OleDbType.UnsignedTinyInt);

            for (int i = 0; i < splittedText1.Length; i++)
            {
                CmdSql.Parameters["@productname"].Value = splittedText1[i];
                CmdSql.Parameters["@productquantity"].Value = splittedText2[i];
                CmdSql.Parameters["@productprice"].Value = splittedText3[i];
                CmdSql.ExecuteNonQuery();
            } 

please help.

2
Contributors
1
Reply
10
Views
3 Years
Discussion Span
Last Post by cgeier
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.