TPLLimited
asked on
Problems counting the number of rows in DataTable
Hi
I am currently trying to create a function to count the number of rows held in a DataTable however I keep getting an Object reference not set to an instance of an object error
Can anyone help with this please?
I am currently trying to create a function to count the number of rows held in a DataTable however I keep getting an Object reference not set to an instance of an object error
Function itemcount() As Integer
Dim itemcounter As Integer = 0
For Each Me.objDR In objDT.Rows
itemcounter = itemcounter + 1
Next
Return itemcounter
End Function
Can anyone help with this please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>For Each Me.objDR In objDT.Rows
your iterator (objDR) should be a new variable:
For Each dr as DataRow In objDT.Rows