//获得对应隶属函数的各个参数 bool GetParasFromDB(int nodenum,int fuctype,int datatype ,Paras& paras){ if(GlDataBase.IsOpen() == TRUE){ CADORecordset recordset(&GlDataBase); map<string,int>::iterator itor; itor = find_if(g_ParaTable.begin(),g_ParaTable.end(),value_equals<string,int>(datatype)); if(itor == g_ParaTable.end()) return false; string str = itor->first; //int id; //CString str; //str.Format("select MAX(层号) from 结点表 where 结点号=%d",j ); CString strQuery; strQuery.Format("select * from rule_unit_sub_table where nodesn = %d and dataname = '%s' and busfun = %d ", nodenum,str.c_str(),fuctype); recordset.SetQuery(strQuery); recordset.Open(); if(recordset.GetRecordCount()==0){ //AfxMessageBox("没有对应的隶属函数!!!"); return false; } else if(recordset.GetRecordCount()>1){ //AfxMessageBox("多于一个隶属函数!!!请修改该规则!!!"); return false; } else if(recordset.GetRecordCount() == 1){ recordset.GetFieldValue(_T("Para1"),paras.para1); recordset.GetFieldValue(_T("Para2"),paras.para2); recordset.GetFieldValue(_T("Para3"),paras.para3); recordset.GetFieldValue(_T("Para4"),paras.para4); recordset.GetFieldValue(_T("Para5"),paras.para5); recordset.GetFieldValue(_T("Para6"),paras.para6); //cout<<endl<<paras.para1; return true; } } return false; }
void CWebSite::GetHomepageFileIdFromDB() { try { ADODB::_RecordsetPtr recordset("ADODB.RecordSet"); recordset->Open( L"websettings", _variant_t(m_connstr), ADODB::adOpenForwardOnly, ADODB::adLockReadOnly, ADODB::adCmdTable); m_homepageFileID = recordset->Fields->Item[_variant_t(L"homepage_fileid")]->Value.lVal; recordset->Close(); } catch(_com_error e) { DbError(e); } }
bool SetParaTable(map<string,int>& ParaTable){ if(GlDataBase.IsOpen() == TRUE){ CADORecordset recordset(&GlDataBase); int id; CString str; //str.Format("select MAX(层号) from 结点表 where 结点号=%d",j ); recordset.SetQuery("select * from 征兆数据"); recordset.Open(); ParaTable.clear(); while(recordset.IsEof()!=TRUE){ recordset.GetFieldValue(_T("征兆数据类型ID"),id); recordset.GetFieldValue(_T("征兆数据类型符号"),str); str.TrimRight(); ParaTable[str.GetBuffer(0)] = id; recordset.MoveNext(); } //cout<<ParaTable.size(); return true; } return false; }
STDMETHODIMP CWebSite::SetHomepageFileId(unsigned long file_id) { try { ADODB::_RecordsetPtr recordset("ADODB.RecordSet"); recordset->Open( L"websettings", _variant_t(m_connstr), ADODB::adOpenForwardOnly, ADODB::adLockOptimistic, ADODB::adCmdTable); recordset->Fields->Item[_variant_t(L"homepage_fileid")]->Value = (long)file_id; recordset->Update(); recordset->Close(); m_homepageFileID = file_id; } catch(_com_error e) { DbError(e); } return S_OK; }
CWBRecordset& CWBDatabase::CreateRecordset(const std::string strQuery) { CWBRecordset recordset(m_pDatabase, strQuery); m_recordsets.push_back(std::move(recordset)); return m_recordsets.back(); }