community server中的小例子...
存储过程中两次select就行了
using( SqlConnection myConnection = GetSqlConnection() )
{
SqlCommand myCommand = new SqlCommand(databaseOwner + ".cs_UserActivityReportRecords_Get", myConnection);
UserActivityResultSet uars = new UserActivityResultSet();
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Pass sproc parameters
myCommand.Parameters.Add("@BegReportDate", SqlDbType.DateTime).Value = BegReportDate;
myCommand.Parameters.Add("@EndReportDate", SqlDbType.DateTime).Value = EndReportDate;
myCommand.Parameters.Add("@nRecordNumberStart", SqlDbType.Int).Value = RecordNumberStart;
myCommand.Parameters.Add("@nRecordNumberEnd", SqlDbType.Int).Value = RecordNumberEnd;
myCommand.Parameters.Add("@Paged", SqlDbType.Bit).Value = 1;
// Execute the command
//
myConnection.Open();
using(SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))
{
// Populate the collection of BlogActivityRecords
//
while (dr.Read())
uars.Records.Add(CommonDataProvider.PopulateUserActivityResultDataFromIReader(dr));
// Get total records
dr.NextResult();
dr.Read();
uars.TotalRecords = (int)dr[0];
dr.Close();
}
myConnection.Close();
return uars;
}