SqlStatement Database::CreateStatement(SqlStatementID& index, const char* fmt) { int nId = -1; //check if statement ID is initialized if (!index.initialized()) { //convert to lower register std::string szFmt(fmt); //count input parameters int nParams = std::count(szFmt.begin(), szFmt.end(), '?'); //find existing or add a new record in registry LOCK_GUARD _guard(m_stmtGuard); PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.find(szFmt); if (iter == m_stmtRegistry.end()) { nId = ++m_iStmtIndex; m_stmtRegistry[szFmt] = nId; } else nId = iter->second; //save initialized statement index info index.init(nId, nParams); } return SqlStatement(index, *this); }
void KviWindow::output(int iMsgType, const QDateTime & datetime, const char * pcFormat, ...) { QString szFmt(pcFormat); kvi_va_list l; kvi_va_start(l, pcFormat); QString szBuf; KviQString::vsprintf(szBuf, szFmt, l); kvi_va_end(l); preprocessMessage(szBuf); const QChar * pC = szBuf.constData(); if(!pC) return; internalOutput(m_pIrcView, iMsgType, (kvi_wchar_t *)pC, 0, datetime); }
void CSpecReporter::OnBnClickedOk() { UpdateData(); ostringstream szFmt(""); vector<string> vtSz; vtSz.push_back( szProName ); //存储过程名 vtSz.push_back((LPCSTR)m_szStart); vtSz.push_back((LPCSTR)m_szEnd); szFmt<<vtType[m_cbType.GetCurSel()] ; vtSz.push_back(szFmt.str() ); CString str; m_cbYear.GetLBText(m_cbYear.GetCurSel(),str); vtSz.push_back( (LPCSTR)str); string szRet; CComFunc::callSqlPro(vtSz,szRet); if( szRet.compare(SZERROR) ) { AfxMessageBox("完成功能"); } else AfxMessageBox("调用存储功能失败"); //_CommandPtr cmd; //_ParameterPtr par; //cmd.CreateInstance(__uuidof( Command )); //par.CreateInstance(__uuidof( Parameter)); //_variant_t vNULL; //vNULL.vt = VT_ERROR; //vNULL.scode = DISP_E_PARAMNOTFOUND; //try{ // cmd->put_CommandType(adCmdStoredProc) ; // //开始期号 // par=cmd->CreateParameter(_bstr_t("start_issn"),adInteger,adParamInput,4,atol(m_szStart)); // cmd->Parameters->Append( par ); // //终止期号 // par=cmd->CreateParameter(_bstr_t("end_issn"),adInteger,adParamInput,4,atol(m_szEnd)); // cmd->Parameters->Append( par ); // //期刊类别 // par=cmd->CreateParameter(_bstr_t("type_issn"),adInteger,adParamInput,4,vtType[m_cbType.GetCurSel()] ); // cmd->Parameters->Append( par ); // //特约通讯员所属年度 // CString str; // m_cbYear.GetLBText(m_cbYear.GetCurSel(),str); // par=cmd->CreateParameter(_bstr_t("year"),adInteger,adParamInput,4,atol(str) ); // cmd->Parameters->Append( par ); // ///* par=cmd->CreateParameter(_bstr_t("ret"),adInteger,adParamOutput,0,vNULL); // cmd->Parameters->Append( par);*/ // cmd->put_CommandText(_bstr_t("prc_compute_reporter")); // cmd->ActiveConnection=HospitalConnect; // cmd->Execute(NULL,NULL,adCmdStoredProc); // //// succ=(long)cmd->Parameters->GetItem("ret")->Value; // cmd.Detach(); // par.Detach(); //} //catch(_com_error e) //{ // AfxMessageBox(e.ErrorMessage()); // return; //} // //AfxMessageBox("成功执行特约通讯员翻番补助操作"); }