博客
_ConnectionPtr pConnection = GetConnection();
_CommandPtr pCommand;
_RecordsetPtr pRs;
try{
pCommand.CreateInstance(__uuidof(Command));
pCommand->ActiveConnection = pConnection;
pCommand->CommandText = "select * from tablename";
pCommand->CommandType = adCmdText;
pCommand->Parameters->Refresh();
pRs = pCommand->Execute(NULL, NULL, adCmdUnknown);
std::vector<std::string> fieldNames;
for (size_t i = 0; i < pRs->GetFields()->GetCount(); i++)
{
fieldNames.emplace_back(pRs->GetFields()->GetItem(_variant_t((long)i))->GetName());
}
...
}
catch (_com_error e){
...
}