Last post Apr 16, 2005 07:39 AM by srobbins
Apr 15, 2005 03:22 PM|srobbins|LINK
In a custom module (DNN3) I am binding an arraylist to a datagrid. Two of the columns are datetime fields. They are defined as datetime fields in the database and in my info class.
In the itemdatabound event I've added code to make the dates display correctly if they happen to be null. The grid is working fine, but I run into a problem when I update the database. When the dates are null, I get the error message "SqlDateTime Overflow.
Must be between 1/1/1753 12:00 AM and 12/31/9999 11:59:59 PM".
Just before calling the update stored procedure in my SqlDataProvider class I can see that the dates are both equal to datetime.minvalue. Am assuming I need to convert them to dbnull.value, but don't know how to do that. Should that conversion be in my
SqlDataProvider class or elsewhere?
Apr 15, 2005 05:03 PM|dantindall|LINK
Apr 15, 2005 05:43 PM|srobbins|LINK
I've tried the following code in the controller class (as well as the SqlDataProvider class):
When I trace I can see that receiptDate is indeed equal to DateTime.MinValue, which causes the error that I mentioned in my original post.
Am I missing something really basic here?
Apr 15, 2005 06:03 PM|dantindall|LINK
Apr 15, 2005 07:01 PM|srobbins|LINK
Change my code per your suggestion. Now it parses, so the build was successful. However, when the stored procedure is called from the sqldataprovider, I still get the same error:
"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM".
In the debugger I can see that the value of receiptDate is #12:00:00 AM#, which is what I'd expect. The database, however, doesn't like it.
Thanks for sticking with me on this. Any other ideas?
Apr 15, 2005 07:17 PM|dantindall|LINK
Apr 15, 2005 07:31 PM|dantindall|LINK
Apr 16, 2005 07:39 AM|srobbins|LINK
Yes! That's it . . .GetNull(receiptDate) in the sqldataprovider class.
I had decided to use a fake date (maybe July 4, 1776 to be patriotic) then test for it, but I wasn't happy about it. Using GetNull is obviously better!
Thanks so much for your help.