JamieWorville
New Member
How do I get a recordcount in asp.net? (Note: I am *not* paging through recordsets.)<BR><BR>But for:<BR><BR> myCommand = New SQLCommand("Select name, lastname from Employees where lastname='Cook'", myConnection )<BR><BR>How do I get a recordcount? <BR>The first query, myCommand1, selects several fields but It won't let me insert this SQL Count(*) into it, so I created a second query. Is that the only way to count records in Asp.Net?<BR><BR>myCommand2 = New SQLCommand("Select COUNT(*) AS RECORDCOUNT from twothousanddescriptions", myConnection )<BR><BR> mydatareader=mycommand2.executereader()<BR> while myDataReader.Read()<BR> response.write (myDataReader.item("recordcount"))<BR> end while<BR> myDataReader.closeIf you want to get the number of records returned, and you do not wish to alter a SQL COUNT(*)-type query, you must use a DataSet. Once you populate the DataSet you can get the Recordcount like so:<BR><BR>Dim i as integer<BR>i = DataSetOject.Tables(0).Rows.Count<BR><BR>hth!