none
DataSet reproduction problem. RRS feed

  • Question

  • Dear colleagues.

     

    I have obtained DataSet that contains a Table with DateTime column. This DataSet contains DateTime that corresponds to winter/summmer switch of DaylightSavingTime. Then I saved this DataSet to XML and Serialize it (ISerializable). Futher loading of DataSet from XML or Deserialization did not occur to the same DateTime value.

     

    I would like save/restore any DataSets to/from files. How can I avoid this reproduction problem?

     

    Thanks.

                         Petr.

    Tuesday, December 25, 2007 10:43 AM

Answers

  • Yes I am. I've already solved the problem by setting

    DateTimeMode to Unspecified. Here is my code:

     

    public static void ConvertToUnspecifiedTime(DataSet dataSet)

    {

    foreach (DataTable dt in dataSet.Tables)

    {

    foreach (DataColumn dc in dt.Columns)

    {

    if (dc.DataType.Equals(typeof(DateTime)))

    {

    dc.DateTimeMode = DataSetDateTime.Unspecified;

    }

    }

    }

    }

     

     

    Thanks/

    Saturday, January 5, 2008 5:47 PM

All replies

  • Are you using the ReadXml and WriteXml methods of DataSet class to load and save your dataset?

     

    Tuesday, December 25, 2007 5:16 PM
  • Yes I am. I've already solved the problem by setting

    DateTimeMode to Unspecified. Here is my code:

     

    public static void ConvertToUnspecifiedTime(DataSet dataSet)

    {

    foreach (DataTable dt in dataSet.Tables)

    {

    foreach (DataColumn dc in dt.Columns)

    {

    if (dc.DataType.Equals(typeof(DateTime)))

    {

    dc.DateTimeMode = DataSetDateTime.Unspecified;

    }

    }

    }

    }

     

     

    Thanks/

    Saturday, January 5, 2008 5:47 PM
  •  

    I am using a SqlDataAdapter to fill my dataset (.net 3.5).    Can I set the DateTimeMode on each column after the dataset has been populated by the data adapter or must i somehow do it prior to executing the data adapter?

     

    thanks!

     

     

     

     

    Friday, March 28, 2008 3:48 PM