The code, compiled found that the problem is to try and leap after execution of the catch statement inside, but this should not be so, don't know what is wrong, please everyone a great god guide
//TODO: add the control notification handler code
Cstrings SqlStr;
//course number were obtained through the course of
The UpdateData ();
_ConnectionPtr pConnection=NULL;
_CommandPtr pCmd=NULL;
_RecordsetPtr pRs=NULL;
Retrieves the hr;//return a status code
_variant_t varFld;
//the Execute function parameter
_variant_t vNULL;
VNULL. N=VT_ERROR;
VNULL. Scode=DISP_E_PARAMNOTFOUND;//no parameters defined as
//to connect
_bstr_t strCnn (SQLCONSTR);
PConnection. CreateInstance (__uuidof (Connection));//connection instance
PConnection - & gt; Open (strCnn, ""," ", NULL);//to establish connection with server
PCmd. CreateInstance (__uuidof (Command));//create a command instance
PCmd - & gt; ActiveConnection=pConnection;//points to the current active connection
SqlStr. The Format (" select KCH from KCB where his='% s' ", m_StuKCM);/l statement
PCmd - & gt; SqlStr CommandText=(_bstr_t);//command text for a SQL statement
//pRs. CreateInstance (__uuidof (you));
//cstrings tempSqlStr;
//tempSqlStr. The Format (" select KCH from KCB where his='% s' ", m_StuKCM);
//pRs - & gt; Open (_variant_t (tempSqlStr), _variant_t (pConnection (IDispatch *), true), adOpenDynamic, adLockOptimistic, adCmdText);
PRs=pCmd - & gt; Execute (& amp; VNULL, & amp; VNULL adCmdText);//the Execute after return the results to the pRs
PRs - & gt; MoveFirst ();
VarFld=pRs - & gt; Fields - & gt; The GetItem (" KCH ") - & gt; The Value;//get the course number
Cstrings StuKCH (_T (varFld bstrVal));
StrKCH=StuKCH;//save KCH
Try
{
//call Load_CJ
_ParameterPtr pParam=NULL;
VNULL. N=VT_ERROR;
VNULL. Scode=DISP_E_PARAMNOTFOUND;//is defined as a no-parameter
Cstrings SqlStr TempZY;
Load_CJ SqlStr. The Format (" ");
PCmd - & gt; SqlStr CommandText=(_bstr_t);
PCmd - & gt; CommandType=adCmdStoredProc;
PParam=pCmd - & gt; CreateParameter (" @ KCH, adVarChar, adParamInput, 16);
PParam - & gt; Value=https://bbs.csdn.net/topics/_variant_t (strKCH);//course number parameter
PCmd - & gt; The Parameters - & gt; Append (pParam);
PParam=pCmd - & gt; CreateParameter (" @ "ZY, adVarChar, adParamInput, 16);
GetDlgItemText (IDC_COMBOZY TempZY);//parameter
PParam - & gt; Value=https://bbs.csdn.net/topics/_variant_t (TempZY);
PCmd - & gt; The Parameters - & gt; Append (pParam);
PRs=pCmd - & gt; Execute (& amp; VNULL, & amp; VNULL adCmdStoredProc);
Cstrings SqlCon="select XH as Stunum, XM as Name, CJ as Grade from tempCJB";
M_ScoreADODC. Put_RecordSource (SqlCon);
M_ScoreADODC. Refresh ();
M_ScoreDATAGRID. The ReBind ();
M_ScoreDATAGRID. Refresh ();
PCmd - & gt; The Parameters - & gt; Delete (_variant_t ((long) 0));//remove parameter
PCmd - & gt; The Parameters - & gt; Delete (_variant_t ((long) 0));
PRs - & gt; Close ();
PConnection - & gt; Close ();
}
The catch (_com_error & amp; E)
{
_bstr_t bstrSource (e.S ource ());
_bstr_t bstrDescription (e.D escription ());
//formatting error string
Cstrings sError;
SError. The Format (Source: % sDescription: "% s", (LPCSTR) bstrSource, (LPCSTR) bstrDescription);
AfxMessageBox (sError);//the pop-up error message
}
}
CodePudding user response:
Code is not long, setting a breakpoint single-step operation, look at what step resulted in the abnormalCodePudding user response:
Now is to add the breakpoint go step by step, go without rhyme or reason to catch it, I am also a small white, no problemCodePudding user response:
Made the pop-up error message to the program to see what is specific content,CodePudding user response:
Is this
CodePudding user response:
Baidu search the corresponding error message,CodePudding user response:
Baidu did not,,Is my statement order wrong great god HELP
CodePudding user response:
See if the database exceptionCodePudding user response:
Normal operation of the database with other database related function is not an error, is this a functionCodePudding user response:
The SQL statement is normal? SQL is correct and see if it take a numeric value corresponding to field correctlyCodePudding user response:
Debug step by step to walk, is normal, but no reason to catch statementCodePudding user response:
Estimates are two close method there anomalies,The pRs - & gt; Close () try to block,
CodePudding user response:
Search "ADO waiting time consuming operation is complete before closing"