How to implement cycle calls for stored procedures in VC?

zhaozj2021-02-16  78

// Declare the object _ConnectionPtr Conn1; _Commandptr CMD1; _RecordSetPtr RS1; _Parameterptr Param

// Initialization

:: Coinitialize (NULL); Param.createInstance ("AdoDb.Parameter");

HRESULT HR = cmd1.createInstance (__ uuidof (command)); if (Failed (HR)) {AFXMessageBox ("_ CommandPtr Initialization Failure"; Return;}

CString strsqlstore; // Organize SQL statement strsqlstore = "Update" Strtablename "set gwerrorcode = 93 where usernumber = paramusernumber;"

/ / Implementation in the program to create a stored procedure_BSTR_T BSTRCREATE (L "Create or Replace Procedure UpdatedB (paramusernumber varchar2)" L "as" L "Begin" strsqlstore L "commit; end;"); _ bstr_t bstrsp (l " updateDB "); m_pCon-> Execute (bstrCreate, NULL, adCmdText); // m_pCon-> Execute (bstrCreate, & RecordsetAffected, amdText); // associative link, m_pCon is already active _ConnectionPtr type of connection Cmd1-> ActiveConnection = M_PCON; cmd1-> commandtex = bstrsp; cmd1-> commandtype = adcmdstoredproc;

// Initialization of the process entry parameter _variant_t varTemp; CString Test; param-> name = "paramusernumber"; param-> type = adchar; param-> size = 20; param-> direction = adParaminput; int y = cmd1- > Parameters-> count; cmd1-> parameters-> append (param); cmd1-> parameters-> refresh ();

// Cycle execute stored procedure CString strsql; while (lineno) {// refresh interface, process other requests MSG msg; while (:: PeekMessage (& MSG, NULL, 0, 0, PM_REMOVE) {:: TranslateMessage (& MSG); :: DispatchMessage (& MSG);} if (m_bexit) {return;}} (m_bstop) {// If there is a suspended message MSG msg; while (:: peekmessage (& msg, null, 0, 0, pm_remove)) {:: TranslateMessage (& MSG); :: DispatchMessage (& MSG);} Sleep (1); if (iDyes == MessageBox ("Is paused to perform a stored procedure?" Prompt ", MB_YESNO MB_ICONQUESTION) RETURN;} // The information of one line represents the value of the entrance parameters to be queried, lineInfo = linearray [lineno];

LineInfo.number = L "'" lineinfo.number l "'"; // parameter formatted

// Parameter assignment // cmd1-> getPrepared (); test = lineinfo.number; varTemp.vt = vt_bstr; VARTEMP.BSTRVAL = (_BSTR_T) TEST; cmd1-> parameters-> item [(short) 0] -> Value = VARTEMP.BSTRVAL;

// Perform a stored procedure CMD1-> Execute (null, null, adcmdstoredproc);

Try {m_PRS-> Open (strsql.allocsystring (), m_pcon.getInterfacePtr (), adopenkeyset, adlickoptimistic, adcmdtext) ;?}

LINENO ; M_ProgressCtrl.Setpos (LINENO);

转载请注明原文地址:https://www.9cbs.com/read-16402.html

New Post(0)