Oracle 5.0 Reference Manual page 1938

Table of Contents

Advertisement

Users of MySQL 5.0.2 and higher can use the new
values. For information on using the
Modes".
20.2.5.12.4. Handling Invalid Dates
Although it is strongly recommended that you avoid the use of invalid dates within your .NET
application, it is possible to use invalid dates by means of the
The
MySqlDateTime
server. The default behavior of Connector/Net is to return a .NET DateTime object for valid date values,
and return an error for invalid dates. This default can be modified to cause Connector/Net to return
MySqlDateTime
To instruct Connector/Net to return a
your connection string:
Allow Zero Datetime=True
Please note that the use of the
known issues:
1. Data binding for invalid dates can still cause errors (zero dates like 0000-00-00 do not seem to
have this problem).
2. The
ToString
2005-02-23
3. The
MySqlDateTime
can cause errors when trying to convert a MySQLDateTime to a DateTime if you do not check for
NULL first.
Because of the known issues, the best recommendation is still to use only valid dates in your
application.
20.2.5.12.5. Handling NULL Dates
The .NET
DateTime
query to a
DateTime
When using a MySqlDataReader, use the
before making the assignment:
Visual Basic Example
If Not myReader.IsDBNull(myReader.GetOrdinal("mytime")) Then
myTime = myReader.GetDateTime(myReader.GetOrdinal("mytime"))
Else
myTime = DateTime.MinValue
End If
C# Example
if (! myReader.IsDBNull(myReader.GetOrdinal("mytime")))
myTime = myReader.GetDateTime(myReader.GetOrdinal("mytime"));
else
myTime = DateTime.MinValue;
values will work in a data set and can be bound to form controls without special handling.
NULL
20.2.5.13. Using the
MySQL Connector/Net features a bulk loader class that wraps the MySQL statement
INFILE. This gives MySQL Connector/Net the ability to load a data file from a local or remote host
Connector/Net Programming
traditional
data type supports the same date values that are supported by the MySQL
objects for invalid dates.
MySqlDateTime
MySqlDateTime
method return a date formatted in the standard MySQL format (for example,
08:50:25). This differs from the
class supports NULL dates, while the .NET DateTime class does not. This
data type cannot handle
variable, you must first check whether the value is in fact NULL.
MySqlBulkLoader
traditional
SQL mode, see
MySqlDateTime
object for invalid dates, add the following line to
class can still be problematic. The following are some
ToString
values. As such, when assigning values from a
NULL
method to check whether a value is
.IsDBNull
Class
1918
SQL mode to restrict invalid date
Section 5.1.7, "Server SQL
data type.
behavior of the .NET DateTime class.
LOAD DATA
NULL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents