Home > Software engineering >  ADO connection to the database in MFC into msado15. Tli GetCollect function of error
ADO connection to the database in MFC into msado15. Tli GetCollect function of error

Time:09-23

The inline _variant_t Recordset15: : GetCollect (const _variant_t & amp; The Index) {
The VARIANT _result;
VariantInit (& amp; _result);
HREULT _hr=get_Collect (Index, & amp; _result);
If (FAILED (_hr)) _con_issue_errorex (_hr, this __uuidof (this));
Return _variant_t (_result, flase);
}
Call this function statements for:
M_listCtrl. SetItemText (0, 0, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t (0) (long)));
Holds the record set for the first column of the data on m_listCtrl controls the position of the first line of the first column,
The first run the program is good, the second time will take the same data error, error message: 0 x045f637b had untreated exception: 0 xc0000005: read position 0 xfeeeff4e when an exception occurs

CodePudding user response:

Look from your description and your code, you seems to be the current record will be moved to the to the location of the BOF or EOF

CodePudding user response:

Yes,
Whie (! Ado. M_Recordset - & gt; AdoEOF) {
M_listCtrl. SetItemText (0, 0, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t (0) (long)));
M_listCtrl. SetItemText (0, 1, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t ((long), 1)));
} ado. Close;
Click the play button key take data, press the button again next time just make a mistake,

CodePudding user response:

Do you want to realize what is the function of every time before entering the while put the position to the first try

CodePudding user response:

reference boylafong reply: 3/f
what do you want to realize what is the function of every time before entering the while put the position to the first line try

To use, read the data in a SQL function is listcrl control disease according to be late

CodePudding user response:

The
reference 1/f, worldy response:
look from your description and your code, you seems to be the current record will be moved to the to the location of the BOF or EOF

See the following code, a while loop, loop nature to adoEOF position, after the next press a button control will go wrong

CodePudding user response:


Whie (! ado. M_Recordset - & gt; AdoEOF {
)M_listCtrl. SetItemText (0, 0, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t (0) (long)));
M_listCtrl. SetItemText (0, 1, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t ((long), 1)));
//here, don't move the current record? Die cycle
} ado. Close ;

Button for the first time, after the red code will ADO object is closed, why do you close?
The second button, the operation is a no record set have failed

CodePudding user response:

refer to 6th floor worldy response:
whie (! ado. M_Recordset - & gt; AdoEOF {
)M_listCtrl. SetItemText (0, 0, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t (0) (long)));
M_listCtrl. SetItemText (0, 1, (LPCTSTR) (_bstr_t) ado. M_Recordset - & gt; GetCollect (_variant_t ((long), 1)));
//here, don't move the current record? Die cycle
} ado. Close ;

Button for the first time, after the red code will ADO object is closed, why do you close?
The second button, the operation is a no have failed the recordset

Mobile, ado. M_Recordset - & gt; MoveNext ();
i++;
Behind the ado. Close () annotation, but also was not used, because every time I press the button to open a thread, are connected, the output after close the connection,

CodePudding user response:

To summarize, commonly 0 xc0000005: while reading position * * * an exception occurs because of a memory leak or pointer problem, I this program because I create threads in the button click event, and then again when data is displayed click on the button, however at this time the thread is not over, although wrote the end of the thread code, but again, click the button, not run to the end of a thread position, cause errors,

CodePudding user response:

Multiple Threads in the User Interface of http://msdn.microsoft.com/zh-cn/library/ms810439.aspx

CodePudding user response:

Read error generally is a pointer to obtain error or operation

CodePudding user response:

If the closing is about to reopen, suggested that the post code, break point is easy to solve this problem

CodePudding user response:

Click the button to run a thread, closing out the thread,
  • Related