OleDbConnection con = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\\incomexp.mdb");
        OleDbCommand com;
             OleDbCommand com = new OleDbCommand("insert  into incomeexp values (@year,@month,@data,@bal,@inc_exp)",con);
                            com.Parameters.Add("@year", OleDbType.Integer);
                            com.Parameters["@year"].Value = yr;
                            com.Parameters.Add("@month", OleDbType.Integer);
                            com.Parameters["@month"].Value = mn;
                            com.Parameters.Add("@data", OleDbType.Char);
                            com.Parameters["@data"].Value = s ;
                            com.Parameters.Add("@bal", OleDbType.Decimal );
                            com.Parameters["@bal"].Value = j ;
                            com.Parameters.Add("@inc_exp", OleDbType.Char);
                            com.Parameters["@inc_exp"].Value = s1 ;



getting error message that
 "Number of query values and destination fields are not the same."

Edited 7 Years Ago by ~s.o.s~: Added code tags, please learn to use them.

i dont know, how many columns your table have, but normally you should write sql-statement like this:

insert into incomeexp (year,month,data,bal,inc_exp) values (@year,@month,@data,@bal,@inc_exp)

Otherwise the order and the amount of table-columns and values must be the same.

And the previous-poster already mentioned: the error-message is always helpfull!!

i hope this helps!

Edited 7 Years Ago by DanielGreen: n/a


I believe the solution Daniel provided will fix your issue. If it doesn't then please post the CREATE TABLE statement for your table.

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