sql - vb.net Date equivalent to String.Empty -
in program, writing class read values in 1 database table, , copy them another. when reading string fields, have function called checks whether or not string value null, , if is, returns empty string, if not, returns string. (see code below)
i have datetime
fields can contain nulls, , without similar function, runtime error when trying copy them.
is there equivalent of code below can use entering in blank date if value in database row null?
public shared function dbtostring(o object) string if o dbnull.value return string.empty else return cstr(o) end if end function
datetime value type, therefore notion of 'blank' doesn't exist. use minvalue
of datetime
there might problems , intent might not clear. use nullable datetime
instead:
public shared function dbtodate(o object) datetime? if o dbnull.value return nothing else return convert.todatetime(o) end if end function
Comments
Post a Comment