1
Answer

Problem with DataSet and Access database

Babak Andisheh

Babak Andisheh

17y
2.1k
1

I am working with an application that communicate with an Access 200 database.
OleDbAdapter and DataSet have been used to read and write to tables in database.
The problem is a column in a table, which has Date/Time type. Every time data of type DateTime sets in this column by DataSet, the Time part of DateTime truncates and only date part puts in database. I tried with OldbCommand and it works well and both Date and time sets in DB but I have to use DataSet in this case. I appreciate any help and suggestion. Here comes code that does not work. 

                       
     DataSet dataset = new DataSet();

     oleDbAdpt.Fill(dataset);
     DataTable dtable = dataset.Tables[0];                     
     DataRow      addingRow = dataset.Tables[0].NewRow();
                               
     addingRow["DATE_CREATED"] = DateTime.Now;
    //addingRow["DATE_CREATED"]=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
               
    dataset.Tables[0].Rows.Add(addingRow);
    oleDbAdpt.Update(dataset.Tables[0]);

Answers (1)