-2
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 ;

                            con.Open();
                            com.ExecuteNonQuery();
                            con.Close();

------------------------------------------------------------------------------------

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

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

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by sknake
0

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 by DanielGreen: n/a

0

sharathk60,

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 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.