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;

outmap[tscolName] =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;

outmap[tscolName] =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;

}

}

outmap[tscolName].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;

}

相关推荐
Dreamcatcher_AC18 小时前
前端面试高频问题解析
前端·css·html
talenteddriver18 小时前
mysql: MySQL索引基础概念
数据库·mysql
king_harry18 小时前
PostgreSQL WAL 原理剖析、日志堆积治理与流复制监控
数据库·postgresql·wal·流复制
默默前行的虫虫18 小时前
nicegui网页多用户数据隔离总结
数据库·sql
damo王19 小时前
how to install npm in ubuntu24.04?
前端·npm·node.js
光影少年19 小时前
Vue 2 / Vue 3 diff算法
前端·javascript·vue.js
野熊佩骑19 小时前
一文读懂运维监控之 Ubuntu22.04安装部署Zabbix监控
linux·运维·服务器·网络·ubuntu·zabbix·database
zhixingheyi_tian19 小时前
Yarn 之 run job
java·开发语言·前端
指尖跳动的光19 小时前
如何减少项目里面if-else
前端·javascript
yanghuashuiyue19 小时前
Vue3难以统一的命名规范
前端·vue.js·typescript