c# - IsDBNull throws an exception -
i'm reading mysql database 1 columns of datetime type. of these dates null. can't seem figure out how check if value null or not. thought isdbnull solve problem, makes no difference @ all
if (!reader.isdbnull(4)) { service.servicedate = reader.getdatetime("servicedate"); }
this exception i'm getting:
"additional information: unable convert mysql date/time value system.datetime"
i tried
if (system.dbnull.value == reader.isdbnull(4))
as as
reader.isdbnull(4).tostring()
and
convert.toboolean(reader.isdbnull(4))
how check without using try catch?
the error not seem have isdbnull - mentions datetime conversion. have tried passing column index getdatetime
, doing isdbnull
?
if (!reader.isdbnull(4)) { service.servicedate = reader.getdatetime(4); }
.
another possibility: convert 0 datetime=true
additionally, after reading other info on error, sounds may need add convert 0 datetime=true
connection string, enables conversion of 0000-00-00 00:00:00
values in datetime
column (if have of those) datetime.minvalue
.
check out of results here: http://www.bing.com/search?q=unable+to+convert+mysql+date%2ftime+value+to+system.datetime&form=ie10tr&src=ie10tr&pc=hpdtdfjs
Comments
Post a Comment