I'm trying to get rows count of SqlDataReader with SQL COUNT(). Because of some technical reasons I can't use a counter (increasing a variable while going forwarder). It's my SQL Statement:
(SELECT * FROM [Menus] WHERE MenuParent=@ID);
(SELECT COUNT(*) AS rowsCount FROM [Menus] WHERE MenuParent=@ID)
And it's my .net code:
(It's simple, C#ers can understand it also)
While DR.Read
If Not DR("rowsCount") Is Nothing Then
temp &= DR("rowsCount")
End If
'blah blah
End While
It does not recognize rowsCount.
What's my wrong?
Whole function: (I used my own classes to connect to the DB) http://pastebin.com/YBZCvvBH
SqlDataReaderfor both. UseNextResultto advance to the next result.