Operator is not valid for type 'DBNull' and type 'DBNull'

Posted by Senthilmcatyr under VB.NET on 9/14/2011 | Points: 10 | Views : 2071 | Status : [Member] | Replies : 1
Hi,
If (Not myTable.Rows(intInd).Item("def_Part") = myTable.Rows(intInd - 1).Item("def_Part")) Or (Not myTable.Rows(intInd).Item("PLAN_DATE") = myTable.Rows(intInd - 1).Item("PLAN_DATE")) Or (Not transDBNull(myTable.Rows(intInd).Item("SHIFT"), "integer") = transDBNull(myTable.Rows(intInd - 1).Item("SHIFT"), "integer")) Or (Not transDBNull(myTable.Rows(intInd).Item("OWNER_NAME"), "string") = transDBNull(myTable.Rows(intInd - 1).Item("OWNER_NAME"), "string")) Then
Dim objNewRow As DataRow = myTable.NewRow
objNewRow.SetColumnError(0, "Total")
caculate(objNewRow, myTable.Rows(intInd - 1))
myTable.Rows.InsertAt(objNewRow, intInd)
Dim objNewComRow As DataRow = objCompareTable.NewRow
objCompareTable.Rows.InsertAt(objNewComRow, intInd)
End If

when i run this code execute this message.
Message: System.InvalidCastException: Operator is not valid for type 'DBNull' and type 'DBNull'. how can i clear this error?



Regards,
SenthilKumar.S




Responses

Posted by: SheoNarayan on: 9/16/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
It is very difficult to read and understand your code. Please give enough space in between the code while posting so that people can easily read and understand, in that case chances are people will help you quickly.

I tried to see your code but lil difficult. Could you explain what are you trying to do and on which line you are getting error (debug to find out this).

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

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

Login to post response