c# and mysql datetime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

currently i'm writing a ADO.Net program using C3 and mysql. i am using
crystal reports by running a mysql query into a DataSet and then using the
DataSet.WriteXMLSchema() function. The problem i'm having is that when i
write the xml schema the mysql datetime column shows up as:

<xs:element name="datesold" msdata:DataType="MySql.Data.Types.MySqlDateTime,
MySql.Data, Version=1.0.4.29851, Culture=neutral, PublicKeyToken=null"
type="xs:string" minOccurs="0" />

and crystal reports does not recognize it in the schema. Is there a way to
change the column?

i tried changing the column type in the dataset but can't change the type
after it's filled. i know i could copy all the data into a datatable, but
there are going to be about 20,000 records in the dataset, so i don't want to
dump the xml or have to run a loop to import it into a datatable.

thanks in advance for any help,
scott
 
When the DataSet was created the DataColumn.DataType was set to be
MySqlDateTime when it looks like you just want System.DateTime.

You should be able to either create the schema before filling the dataset
and convert the data from MySqlDateTime to DateTime on each row added or
after filling the dataset, add a new DateTime column, convert/copy all the
data, remove the MySqlDateTime column.

After that call DataSset.WriteXmlSchema.

For example, compare the output of
DataSet ds = new DataSet("DataSet");
ds.Tables.Add("Table").Columns.Add("Col1", typeof(System.DateTime));
ds.WriteXmlSchema(System.Console.Out);
vs
DataSet ds = new DataSet("DataSet");
ds.Tables.Add("Table").Columns.Add("Col1",
typeof(System.Data.OracleClient.OracleDateTime));
ds.WriteXmlSchema(System.Console.Out);
 
Back
Top