// GetConnection()自定义函数,获取连接指针,类型_ConnectionPtr
_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());
}
... // fieldNames列名集合
}
catch (_com_error e){
...
}
VC++获取Access查询的列名
猜你喜欢
转载自blog.csdn.net/qq_44575789/article/details/122269837
今日推荐
周排行