public int GetTotalRows()
{
SqlCommand myComm = new SqlCommand("SELECT COUNT(*) FROM Tracks", myConnection2);
int totalRows = 0;
SqlDataReader dataReader;
dataReader = myComm.ExecuteReader();
while (dataReader.Read())
{
totalRows++;
}
dataReader.Close();
return totalRows;
}
Returns 1.
Use totalRows = Convert.ToInt32( SqlCommand.ExecuteScalar() );
The query returns the number of rows.
GetTrackData:
if(dataReader.Read())
{
td.SetTrackData(dataReader.GetString(0),
dataReader.GetString(1),
dataReader.GetString(2));
}
Regards
Espen Harlinn