db 获取队列

int DbHelper::GetSqlTempTable(const DeviceCfg &devcfg,const string& sql,map<TString,vector<TString>>& outmap,vector<TString>& mapheader ,string& err ,TString DbDirFile)

if(dbCon.Open(err)){

try{

int rowIndex =0;

_RecordsetPtr pRecordset = dbCon.ExecSql(sql);

//获取列名

if(pRecordset)

{

int count =pRecordset->Fields->GetCount();

for(int i = 0; i <count ; i++)

{

BSTR bstrColName;

FieldPtr fieldPtr= pRecordset->Fields->GetItem(_variant_t((long)i));

if(fieldPtr){

fieldPtr->get_Name(&bstrColName);

string colName =_com_util::ConvertBSTRToString(bstrColName);

//colName.append((LPCSTR)bstrColName,strlen((LPCSTR)bstrColName));

TString tscolName =utils::ASCIIToUNICODE(colName);

if(outmap.find(tscolName) == outmap.end()){

vector<TString> tempvec;

outmaptscolName =tempvec;

mapheader.push_back(tscolName);

}

}

fieldPtr->Release();

}

}else{

err="sql 执行为空";

return -1;

}

while (pRecordset &&!pRecordset->adoEOF){

for(int i = 0; i < pRecordset->Fields->GetCount(); i++)

{

TString tscolName ;

string result;

BSTR bstrColName;

FieldPtr fieldPtr= pRecordset->Fields->GetItem(_variant_t((long)i));

if(fieldPtr){

fieldPtr->get_Name(&bstrColName);

string colName =_com_util::ConvertBSTRToString(bstrColName);

tscolName =utils::ASCIIToUNICODE(colName);

if(outmap.find(tscolName) == outmap.end()){

vector<TString> tempvec;

outmaptscolName =tempvec;

}

}

fieldPtr->Release();

if(pRecordset->GetCollect(_variant_t((long)i)).vt != VT_NULL)

{

_bstr_t value = (_bstr_t)pRecordset->GetCollect(_variant_t((long)i));

if(strlen((LPCSTR)value) > 0){

result= value;

}

}

outmaptscolName.push_back(utils::ASCIIToUNICODE(result));

}

rowIndex++;

pRecordset->MoveNext();

if(count++ >1000)

break;

}

dbCon.CloseDataSet(pRecordset!=NULL);

}

catch(_com_error& e)

{

LOG_ERR(_T("com_err %s"),(TCHAR*)e.Description());

err = utils::SZFormat("com_err %s",e.Description());

return -2;

}

catch(...){

err = "未知错误";

}

}else{

return -2;

}

相关推荐
IvorySQL3 小时前
PostgreSQL 日报|恢复期 COPY TO 未日志表修复(10 月 21 日)
数据库·postgresql·区块链
程序员海军3 小时前
用了两年多 GPT,我最近开始换模型了,还折腾了个求职避坑 Agent
前端·人工智能·后端
zttbee3 小时前
echarts图表tooltip色块失效
前端·javascript·echarts
贝猫说python4 小时前
大模型比赛2.3智能体开发(工具调用智能问答助手)
数据库·oracle
Cry丶4 小时前
ubuntu安装vsftpd
服务器·网络·ubuntu
excel5 小时前
IndexNow:让搜索引擎更快发现网站更新的主动通知协议
前端·后端·架构
子兮曰5 小时前
CSS 复现 23 种设计风格:从拟物到液态玻璃的成本阶梯与兜底写法【实战】
前端·css·视觉设计
许彰午5 小时前
28-ORA-01110数据文件读取错误
数据库·oracle
凯凯姜5 小时前
MySQL 联合索引设计与索引失效
数据库·mysql
虚无境5 小时前
如何用AI帮我写出实用的插件
前端·javascript·ai编程