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

Recommended Answers

All 2 Replies

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!

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.

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.