0

xml serialization in .Net with datetime

by Deepak Dhakal 8. December 2011 11:22

If you have

<xs:element name="start" type="xs:date"/>

make sure you parse as

<start>2002-09-24</start>

 

or if you have

<xs:element name="startdate" type="xs:dateTime"/>

 

you parse as

<startdate>2002-05-30T09:30:10.5</startdate>

 

if you don't then you will get error like

at System.DateTimeParse.ParseExactMultiple(String s, String[ formats, DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String[ formats, IFormatProvider provider, DateTimeStyles style)
at System.Data.SQLite.SQLiteConvert.ToDateTime(String dateText)
at System.Data.SQLite.SQLiteConvert.ToDateTime(IntPtr ptr, Int32 len)
at System.Data.SQLite.SQLite3.GetDateTime(SQLiteStatement stmt, Int32 index)
at System.Data.SQLite.SQLite3.GetValue(SQLiteStatement stmt, Int32 index, SQLiteType typ)
at System.Data.SQLite.SQLiteDataReader.GetValue(Int32 i)
at System.Data.SQLite.SQLiteDataReader.GetValues(Object[ values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[ values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()br /> at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[ dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[ datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[ dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at WindowsFormsApplication2.AssetManagerDBDataSetTableAdapters.AssetsTableAdapter.Fill(AssetsDataTable dataTable) in C:\Users\Administrator\Desktop\SQLite Version\WiscoAssetImporter\AssetManagerDBDataSet1.Designer.cs:line 4408
at WindowsFormsApplication2.FormMerge.FormAnalyse_Load(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\SQLite Version\WiscoAssetImporter\FormMerge.cs:line 71

Tags:

Powered by BlogEngine.NET 1.5.0.7
Original Design by Laptop Geek, Adapted by onesoft