I am gettting the following 2 errors:
Invalid attempt to call Read when reader is closed
and sometimes
Invalid attempt to call MetaData when reader is closed
when attempting to read from a sqldatareader object. What I want is to list groups in listview. The last column is "Total Numbers".
It works ok for the first row but after that the first error generates. How can I do this? I don't want to include the COUNT function in the main sql cos then i would be required to group the rest fields (there are 9 of them totally). I tried MARS but it don't work at all in my connection which is like:
Invalid attempt to call Read when reader is closed
and sometimes
Invalid attempt to call MetaData when reader is closed
when attempting to read from a sqldatareader object. What I want is to list groups in listview. The last column is "Total Numbers".
Code:
while reader.read
'fill lv here.
'last column value is calculated from a function that does db operation
lvitem.subitems.add(totalItems(reader.item("id"))
end while
function totalItems(byval id as integer) as integer
//reader operation goes here from query like select count(*) as total from tbl where field=id
end function
Code:
public dbconnection as new sqlclient.connection dbconnection.connectionstring=strconnection
Comment