一 获得每个学生的成绩
?
_RecordsetPtr pRecordSet;
pRecordSet.CreateInstance(_uuidof(Recordset));
CString recordStr;
recordStr.Format (_T("Select * from 课堂成绩表%d order by 学号 "),
m_pParentStudentInfo->m_nXueqiID);
try{
pRecordSet->Open(
(LPCTSTR)recordStr,
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText
);
if (!pRecordSet->adoBOF)
{
pRecordSet->MoveFirst ();
}else
return; //数据库为空
CString nXuehaoStr;
CString nameStr;
CString youxiuStr;
CString liangStr;
CString jiayouStr;
CString kuangkeStr;
_variant_t varValue;
unsigned nCount=0;
while (!pRecordSet->adoEOF)
{
varValue=pRecordSet->GetCollect(_T("学号"));
if (varValue.vt!=VT_NULL)
{
nXuehaoStr=((LPCTSTR)_bstr_t(varValue));
if (_ttoi(nXuehaoStr)==0) //特殊学生 保存其他信息
{
pRecordSet->MoveNext ();
continue;
}
}else{
pRecordSet->MoveNext ();
continue;
}
varValue=pRecordSet->GetCollect (_T("姓名"));
if (varValue.vt!=VT_NULL)
{
nameStr=(LPCTSTR)_bstr_t(varValue);
}else
nameStr=L"";
varValue=pRecordSet->GetCollect (_T("优秀"));
if (varValue.vt!=VT_NULL)
{
youxiuStr=(LPCTSTR)_bstr_t(varValue);
}else
youxiuStr=L"0";
varValue=pRecordSet->GetCollect (_T("良"));
if (varValue.vt!=VT_NULL)
{
liangStr=(LPCTSTR)_bstr_t(varValue);
}else
liangStr=L"0";
varValue=pRecordSet->GetCollect (_T("一般"));
if (varValue.vt!=VT_NULL)
{
jiayouStr=(LPCTSTR)_bstr_t(varValue);
}else
jiayouStr=L"0";
varValue=pRecordSet->GetCollect (_T("旷课"));
if (varValue.vt!=VT_NULL)
{
kuangkeStr=(LPCTSTR)_bstr_t(varValue);
}else
kuangkeStr=L"0";
m_StuKetangScoreList.InsertItem(nCount,nXuehaoStr);
m_StuKetangScoreList.SetItemText(nCount,1,nameStr);
m_StuKetangScoreList.SetItemText(nCount,2,youxiuStr);
m_StuKetangScoreList.SetItemText(nCount,3,liangStr);
m_StuKetangScoreList.SetItemText(nCount,4,jiayouStr);
m_StuKetangScoreList.SetItemText(nCount,5,kuangkeStr);
nCount++;
pRecordSet->MoveNext ();
}
}
catch(_com_error & e)
{
AfxMessageBox(e.ErrorMessage());
}
获得班级信息
?
_RecordsetPtr pRecordSet;
pRecordSet.CreateInstance(_uuidof(Recordset));
CString recordStr;
recordStr.Format (_T("Select * from ClassInfo order by 入学年,班级,ID"));
try{
pRecordSet->Open(
(LPCTSTR)recordStr,
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText
);
if (!pRecordSet->adoBOF)
{
pRecordSet->MoveFirst ();
}else
return; //数据库为空
CString ruxueNianStr;
CString banjiStr;
CString xueqiStr;
_variant_t varValue;
unsigned nCount=0;
int nID=0;
int banjiID=0;
BOOL bSelected=FALSE;
short nDianming=0;
while (!pRecordSet->adoEOF)
{
varValue=pRecordSet->GetCollect(_T("点名"));
if (varValue.vt!=VT_NULL)
{
nDianming=_ttoi((LPCTSTR)_bstr_t(varValue));
}else
nDianming=0;
varValue=pRecordSet->GetCollect(_T("入学年"));
if (varValue.vt!=VT_NULL)
{
ruxueNianStr=(LPCTSTR)_bstr_t(varValue);
}else
continue;
varValue=pRecordSet->GetCollect (_T("班级"));
if (varValue.vt!=VT_NULL)
{
banjiStr=(LPCTSTR)_bstr_t(varValue);
}else
continue;
varValue=pRecordSet->GetCollect (_T("学期"));
if (varValue.vt!=VT_NULL)
{
xueqiStr=(LPCTS