public void purchaseProduct(string productname, string challan_no, DateTime challan_date, string bill_no, DateTime bill_date, string Customer,string InvoiceNo)
{
con.Open();
OleDbCommand insert = new OleDbCommand("INSERT INTO [PRODUCT_DETAILS]([PRODUCT_NAME],[CHALLAN_NO],[CHALLAN_DATE],[BILL_NO],[BILL_DATE],[CUST_NAME],[INVOICE_NO])VALUES('"+productname+"','"+challan_no+"',"+challan_date+",'"+bill_no+"',"+ bill_date +",'"+Customer+"','"+InvoiceNo+"')", con);
insert.ExecuteNonQuery();
MessageBox.Show("Your data has been saved.");
}
How to save date in access database from datetime picker in c#. I have passed values in the following manner:
add.purchaseProduct(txtproductname.Text.ToUpper(), txtchallan_no.Text.ToUpper(), txtchallan_date.Value, txtbill_no.Text.ToUpper(), txtbill_date.Value, txtCustomer.Text.ToUpper(), invoiceNo);
I have tried hash in front of date but i ddidnt succed. How to save date in access date/Time datatype format in access.
How to save date in access database from datetime picker in c#. I have passed values in the following manner:
add.purchaseProduct(txtproductname.Text.ToUpper(), txtchallan_no.Text.ToUpper(), txtchallan_date.Value, txtbill_no.Text.ToUpper(), txtbill_date.Value, txtCustomer.Text.ToUpper(), invoiceNo);
I have tried hash in front of date but i ddidnt succed. How to save date in access date/Time datatype format in access.
VulpesPosted Jun 22, 2012, 4:56 AM
Consequently, you're attempting to convert from a DateTime to a string, rather than the other way around.
Is it possible that the error may refer to a different part of the code?
rimmi anandPosted Jun 21, 2012, 12:03 AM
Satyapriya NayakPosted Jun 20, 2012, 2:01 PM
Try
'" +dateTimePicker1.Value.Date.ToString() + "'
Thanks
VulpesPosted Jun 20, 2012, 1:54 PM