Re: What changed with MySqlDbType.Datetime?
Reggie,
Here is an alternative way of validating DateTime for the MySqlDateTime.Seralize()
This check the value in the even the time has been removed from the datetime which is a possiabilty if the user is working with a control that formats the DateTime to a ShortDate().
if (value is MySqlDateTime)
value = (value as MySqlDateTime).GetDateTime();
//
// if (! (value is DateTime))
// throw new MySqlException( "Only DateTime objects can be serialized by MySqlDateTime" );
DateTime dtValue;
try
{
System.Globalization.DateTimeFormatInfo mDate = new System.Globalization.DateTimeFormatInfo();
dtfi.ShortDatePattern = "M/d/yyyy";
dtValue = DateTime.ParseExact( value.ToString(), "d", mDate );
}
catch(Exception)
{
throw new MySqlException( "Only DateTime objects can be serialized by MySqlDateTime" );
}
Subject
Written By
Posted
November 18, 2004 08:20AM
November 18, 2004 08:32AM
November 18, 2004 10:37AM
Re: What changed with MySqlDbType.Datetime?
November 18, 2004 02:43PM
November 19, 2004 06:51AM
November 29, 2004 10:14AM
November 29, 2004 10:17AM
November 29, 2004 11:04AM
November 29, 2004 07:40PM
November 30, 2004 11:07AM
December 03, 2004 04:42PM
December 09, 2004 02:43PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.