64,674
社区成员
发帖
与我相关
我的任务
分享
CString strSql= "select * from sysalarm1 where id = (select max(id) from sysalarm1)";
m_pMain->retrieveData(strSql);
_variant_t varData;
CString varStr[12];
while(!m_pMain->pRecordset1->EndOfFile)
{
varData = m_pMain->pRecordset1->GetCollect("name");
if (varData.vt!=VT_NULL )
varStr[1] = varData;
else
varStr[1] = "";
m_pMain->pRecordset1->MoveNext();
}
m_pMain->pRecordset1->Close();
int Cwelcome::retrieveData(CString strSql)
{
_ConnectionPtr pConn;
_RecordsetPtr pRecordset;
_bstr_t bstrSQL;
CString errormessage;
bstrSQL = strSql;
try
{
pRecordset->Open(bstrSQL,pConn.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
}
catch(_com_error e)
{
errormessage.Format("数据库读写失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
return -1;
}
return 0;
}