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;

}

相关推荐
百万蹄蹄向前冲1 分钟前
Trae分析Phaser.js游戏《洋葱头捡星星》
前端·游戏开发·trae
Viking_bird18 分钟前
centos 7.5 + Hadoop 3.2.4 集群搭建
linux·运维·服务器·hadoop·centos
朝阳58139 分钟前
在浏览器端使用 xml2js 遇到的报错及解决方法
前端
GIS之路1 小时前
GeoTools 读取影像元数据
前端
ssshooter1 小时前
VSCode 自带的 TS 版本可能跟项目TS 版本不一样
前端·面试·typescript
Jerry2 小时前
Jetpack Compose 中的状态
前端
weixin_307779133 小时前
VS Code配置MinGW64编译SQLite3库
开发语言·数据库·c++·vscode·算法
dae bal3 小时前
关于RSA和AES加密
前端·vue.js
柳杉3 小时前
使用three.js搭建3d隧道监测-2
前端·javascript·数据可视化
SelectDB3 小时前
Apache Doris 4.0 AI 能力揭秘(一):AI 函数之 LLM 函数介绍
数据库·人工智能·数据分析