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;

}

相关推荐
今天AI了吗1 小时前
Python 基础语法(一):常量、变量、输入输出与运算符
开发语言·数据库·人工智能·python·sql·深度学习·机器学习
风月说与山鬼1 小时前
三、大括号语法
前端·react.js
liuyicenysabel1 小时前
多服务上线日记三:
运维·服务器·笔记·学习
kyriewen1 小时前
我把最常踩的8个CORS跨域报错整理了一遍——第8个去年还不存在
前端·javascript
Csvn2 小时前
🕰️ 闭包 + setTimeout 的 5 个经典陷阱:为什么定时器看到的永远不是最新的值?
前端
lilian2332 小时前
Harmony os 技术实战|拼豆制图27:用单字符编码承载 50 张 70×70 图纸
前端·数据库·华为·harmonyos
吠品2 小时前
Wine 在 Linux 上运行 Windows 软件完整指南
java·linux·服务器
皮卡丘不断更3 小时前
手机优先的 Personal Ledger:把账目、学习和复盘放到同一个入口
数据库·sqlite·fastapi·开源项目·个人效率
CarIise3 小时前
CSS选择器与样式关联
前端·css·tensorflow