I am working in charp with access database. I have made a function and passed values. all fields values are correct but it is showing "Data type mismatch in expression criterian". I have one date picker. how to save it in database.
My function is like this:
Please help me soon with this where i am wrong. I have to submit my project and also data is also saving in the access.
My function is like this:
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=jewellarydb.accdb;"); public void purchaseProduct(string productname, string challan_no, string challan_date, string bill_no, string bill_date, string Customer) { try { if (con.State != ConnectionState.Open) { con.Open(); OleDbCommand insert = new OleDbCommand("INSERT INTO [PRODUCT_DETAILS](PRODUCT_NAME,CHALLAN_NO,CHALLAN_DATE,BILL_NO,BILL_DATE,CUST_NAME)VALUES('" + productname + "','" + challan_no + "','" + challan_date + "','" + bill_no + "','" + bill_date + "','" + Customer + "')", con); insert.ExecuteNonQuery(); MessageBox.Show("Your data has been saved."); } } catch(Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } add.purchaseProduct(txtproductname.Text.ToUpper(), txtchallan_no.Text.ToUpper(), txtchallan_date.Value.ToShortDateString(), txtbill_no.Text.ToUpper(), txtbill_date.Value.ToShortDateString(), txtCustomer.Text.ToUpper());
Please help me soon with this where i am wrong. I have to submit my project and also data is also saving in the access.
Last edited by a moderator: