riant_t vCount = m_pRecordset->GetCollect(vIndex);
///取得第一个字段的值放入vCount变量
m_pRecordset->Close();///关闭记录集
m_pRecordset.Release();
CString Message;
Message.Format("最大值是%d",vCount.lVal);
AfxMessageBox(Message);
}
void CTestadoView::OnOldMin()
{
_RecordsetPtr m_pRecordset;
_variant_t RecordsAffected;
m_pRecordset =m_pConnection->Execute("select MIN(old) from new",&RecordsAffected,adCmdText);
_variant_t vIndex = (long)0;
_variant_t vCount = m_pRecordset->GetCollect(vIndex);
///取得第一个字段的值放入vCount变量
m_pRecordset->Close();///关闭记录集
m_pRecordset.Release();
CString Message;
Message.Format("最小值是%d",vCount.lVal);
AfxMessageBox(Message);
}
void CTestadoView::OnOldTotal()
{
_RecordsetPtr m_pRecordset;
_variant_t RecordsAffected;
m_pRecordset =m_pConnection->Execute("select SUM(old) from new",&RecordsAffected,adCmdText);
_variant_t vIndex = (long)0;
_variant_t vCount = m_pRecordset->GetCollect(vIndex);
///取得第一个字段的值放入vCount变量
m_pRecordset->Close();///关闭记录集
m_pRecordset.Release();
CString Message;
Message.Format("总和是%d",(long)vCount);
AfxMessageBox(Message);
}
void CTestadoView::OnOldAverage()
{
_RecordsetPtr m_pRecordset;
_variant_t RecordsAffected;
m_pRecordset =m_pConnection->Execute("select AVG(old) from new",&RecordsAffected,adCmdText);
_variant_t vIndex = (long)0;
_variant_t vCount = m_pRecordset->GetCollect(vIndex);
///取得第一个字段的值放入vCount变量
m_pRecordset->Close();///关闭记录集
m_pRecordset.Release();
CString Message;
Message.Format("平均值是%d",(long)vCount);
AfxMessageBox(Message);
}}
运行
程序,执行菜单当中的汇总命令,我们可以得到相关的汇总信息。