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;

}

相关推荐
IT_陈寒1 小时前
React的useState居然还有这种坑?我差点删库跑路
前端·人工智能·后端
Pedantic3 小时前
SwiftUI 手势笔记
前端·后端
橙子家3 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
前端
user20585561518133 小时前
X6 中边悬浮置顶,规避 `mouseleave` 事件丢失问题
前端
李明卫杭州3 小时前
CSS aspect-ratio 属性完全指南
前端
Pedantic5 小时前
SwiftUI 手势层级(Gesture Hierarchy)详解
前端
飘尘5 小时前
前端转型全栈(Java后端)的快速上手指引
前端·后端·全栈
一颗烂土豆5 小时前
Meshopt 压缩深度解析,为什么它比 Draco 更快
前端·javascript·webgl
浏览器工程师6 小时前
AI Agent 接浏览器任务,先别让它一路点到底
前端·后端