Operator is not valid for type 'DBNull' and type 'Date'.http://www.dotnetforums.net/n

bkedersha

Newcomer
Joined
Aug 2, 2005
Messages
13
A previous developer created this page using FrontPage 2003. I know you cannot have an empty dataset. Is there anyway around this problem in VB.net and aspt.net

http://www.xtremedotnettalk.com/newthread.php?do=newthread&f=62#
Confused

Operator is not valid for type 'DBNull' and type 'Date'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Operator is not valid for type 'DBNull' and type 'Date'.

Source Error:


Line 25: end select
Line 26: if not page.ispostback
Line 27: select case session("CurrentGrantExpDate") < now()
Line 28: case true
Line 29: lblNewExpDate.visible=false


Source File: D:\GrantManagementWeb\TimeAmendmentForm.aspx Line: 27

Stack Trace:



[InvalidCastException: Operator is not valid for type 'DBNull' and type 'Date'.]
Microsoft.VisualBasic.CompilerServices.ObjectType.ThrowNoValidOperator(Object obj1, Object obj2) +562
Microsoft.VisualBasic.CompilerServices.ObjectType.ObjTst(Object o1, Object o2, Boolean TextCompare) +2740
ASP.TimeAmendmentForm_aspx.Page_Load(Object Sender, EventArgs e) in D:\GrantManagementWeb\TimeAmendmentForm.aspx:27
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750 :confused: :confused: :confused:
 
Visual Basic:
end select 
if not page.ispostback
if not session("CurrentGrantExpDate")  is dbnull.value then 'check it's not null
select case session("CurrentGrantExpDate") < now()
case true
lblNewExpDate.visible=false

:)
 
Back
Top