Invalid Exception for DB null

Posted by Senthilmcatyr under VB.NET on 9/15/2011 | Points: 10 | Views : 1051 | Status : [Member] | Replies : 1
Hi,
System.InvalidCastException: Operator is not valid for type 'DBNull' for this line

If Not CType(objRow.Item("PLAN_DATE"), String).Length < 7 Then
objRow.Item("PLAN_DATE") = CType(objRow.Item("PLAN_DATE"), String).Insert(4, "/")
objRow.Item("PLAN_DATE") = CType(objRow.Item("PLAN_DATE"), String).Insert(7, "/")
End If

How its solve?




Responses

Posted by: Vuyiswamb on: 9/15/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
There is no data in this

(objRow.Item("PLAN_DATE")


its null, check if there are any nulls in that Field from the DB, and do

Isnull(PLAN_DATE,getdate()
)

or min date just to pass data


Thank you for posting at Dotnetfunda
[Administrator]

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response