problem while inserting to access database

Jul 13 2012 7:40 AM
am getting problem while inserting the below query to access database from c# its showing exception as syntax error at insert to statement please help me
thanks in advance..

string date = dateTimePicker1.Value.ToString("MM/dd/yyyy");
            int from=Convert.ToInt32(com_from.SelectedValue.ToString());
            int to=Convert.ToInt32(com_to.SelectedValue.ToString());

            //string partyname=(((DataRowView)com_class.SelectedItem)["class_name"]).ToString();
            int partyname = Convert.ToInt32(com_party.SelectedValue.ToString());
            int carno = Convert.ToInt32(com_carnum.SelectedValue.ToString());
            int advance = Convert.ToInt32(txt_advance.Text);
            int total = Convert.ToInt32(txt_gndtot.Text);

          
                    int closingkm=Convert.ToInt32(txt_closingkm.Text);
                    int startingkm = Convert.ToInt32(txt_startingkm.Text);

                    string query = "insert into bill(billdate,from,to,partyname,carnumber,closingkm,startingkm,total,advance) values(" + date.ToString() + "," + from + "," + to + "," + partyname + "," + carno + "," + closingkm + "," + startingkm + ","+ total +","+ advance +")";
                   
                    con = new OleDbConnection(s);
                    con.Open();
                    cmd = new OleDbCommand(query, con);

                    cmd.ExecuteNonQuery();
                    con.Close();



---------
Thanks in advance
Znaneswar

Answers (1)