smalldatetime Null in SQL for ASP.net Page

G

Guest

I have a database with a field used for an approval date set as a
smalldatetime. When the record is initially written it is intended to be
reviewd and approved. However until it is approved it has a null value,
which throws an error in the ASP page that is intended to be used to review
and update. The error is th DBNull to DateTime conversion error.

Any Suggestions?
 
G

Guest

Patirck,

Thanks for the quick response. I actually found the solution and will
include it for any other searches

My old code was:

Request.ApprovedDate = drRequests.Item("ApprovedDate")

I wrote new code as follows:

If IsDBNull(drRequests.Item("ApprovedDate")) Then
Request.ApprovedDate = " "
Else
Request.ApprovedDate = Format(drRequests.Item("ApprovedDate"), "d")
End If


Thanks,
 
P

Patirck Ige

Good you got it working Robert
Patrick

Robert Willhite said:
Patirck,

Thanks for the quick response. I actually found the solution and will
include it for any other searches

My old code was:

Request.ApprovedDate = drRequests.Item("ApprovedDate")

I wrote new code as follows:

If IsDBNull(drRequests.Item("ApprovedDate")) Then
Request.ApprovedDate = " "
Else
Request.ApprovedDate = Format(drRequests.Item("ApprovedDate"), "d")
End If


Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top