(ADO v2.20) pRs->Delete(); Crashes the application
-
Using the class "A set of ADO classes - version 2.20 By Carlos Antollini" Trying to delete the current record set with the following code if (pRs->IsOpen()) { if (!pRs->IsEOF()) pRs->Delete(); } the application craches with "unhandled exception in App.exe (kernel32.dll) 0xe06d7363:Microsodt C++ Exception. What seems to be worng ? sdancer
-
Using the class "A set of ADO classes - version 2.20 By Carlos Antollini" Trying to delete the current record set with the following code if (pRs->IsOpen()) { if (!pRs->IsEOF()) pRs->Delete(); } the application craches with "unhandled exception in App.exe (kernel32.dll) 0xe06d7363:Microsodt C++ Exception. What seems to be worng ? sdancer
first put your code inside a try catch block:
try { //your ADO code } catch(_com_error &err) { AfxMessageBox(err.Description()); }
this will issue a message box with the error description returned by the ADO.Recordset object no body can help you with this error with the information you supplied here!! k_dehairy -
first put your code inside a try catch block:
try { //your ADO code } catch(_com_error &err) { AfxMessageBox(err.Description()); }
this will issue a message box with the error description returned by the ADO.Recordset object no body can help you with this error with the information you supplied here!! k_dehairy -
Using the class "A set of ADO classes - version 2.20 By Carlos Antollini" Trying to delete the current record set with the following code if (pRs->IsOpen()) { if (!pRs->IsEOF()) pRs->Delete(); } the application craches with "unhandled exception in App.exe (kernel32.dll) 0xe06d7363:Microsodt C++ Exception. What seems to be worng ? sdancer
The commands before Rs->IsOpen() is a Select query statement with outter Left join to other tables, and it works fine when i try to show them. It is just used in a ShowRecord Dialog with a Delete Button to delete the current record that is shown currently in the window objects. The MoveNext() & MovePrevious() buttons works just fine. Regards, George sdancer
-
The commands before Rs->IsOpen() is a Select query statement with outter Left join to other tables, and it works fine when i try to show them. It is just used in a ShowRecord Dialog with a Delete Button to delete the current record that is shown currently in the window objects. The MoveNext() & MovePrevious() buttons works just fine. Regards, George sdancer
you still need to put your ADO code in a try .. catch blocks, just like what I pointed earlier. then tell me what did the messagebox say. generally speeking any code that deals with COM objects (like ADO) is better written inside try .. catch blocks. k_dehairy
-
you still need to put your ADO code in a try .. catch blocks, just like what I pointed earlier. then tell me what did the messagebox say. generally speeking any code that deals with COM objects (like ADO) is better written inside try .. catch blocks. k_dehairy
Trying the code you said, i receive the following error. if (!pRs->IsEOF()) { try { pRs->Delete(); } catch(_com_error &err) { AfxMessageBox(err.Description()); return; } } (I will make an english translation of the error code since i get it in Greeks) "It was not possible to find the row for update.Its possible that some values have changed since the last read." What Seems to be the problem ? Below is the OnInitDialog() code and you can see the select query. BOOL CBookProperties::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here CString strSQL,strVal; wchar_t buffer[20]; m_Sheet.AddPage (&m_SheetBasic); m_Sheet.AddPage (&m_SheetDetails); m_Sheet.AddPage (&m_SheetExtras); m_Sheet.AddPage (&m_SheetPhoto); m_Sheet.Create (this, WS_TABSTOP | WS_CHILD | WS_VISIBLE,WS_EX_CONTROLPARENT); m_Sheet.SetWindowPos (NULL,0,100, 0,0,SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); //NEW Record if (m_mode == NEW) { m_bNext.EnableWindow (FALSE); m_bPrevious.EnableWindow (FALSE); m_bPrint.EnableWindow (FALSE); m_bDelete.EnableWindow (FALSE); } else //EDIT VIEW Record { pAdoDb = new CADODatabase(); try { if (pAdoDb->Open(((CLibrarianApp*)AfxGetApp())->m_strConnection)) { pRs = new CADORecordset(pAdoDb); _ultow( m_lRecSQLCode, buffer, 10 ); //find the specific record strSQL=_T("SELECT Books.*, Categories.CategoryDesc, Author1,PublishHouses.PublishHouseDesc ") _T("FROM books LEFT OUTER JOIN Categories ") _T("On Books.CategoryID=Categories.CategoryID LEFT OUTER JOIN PublishHouses ") _T("On Books.CategoryID=PublishHouses.PublishHouseID ") _T("WHERE BookID=") + CString(buffer) + " " _T("ORDER BY title,author1,categoryDesc ASC"); if (pRs->Open(strSQL,CADORecordset::openQuery) ) { SetRecordValues(); UpdateData(FALSE); m_lAbsRecPosition=pRs->GetAbsolutePosition(); pRs->Close(); } else { pRs->Close(); delete pRs; } //now set a global query to use with next & previous button strSQL=_T("SELECT Books.*, Categories.CategoryDesc, Author1,PublishHouses.PublishHouseDesc ") _T("FROM books LEFT OUTER JOIN Categories ") _T("On Books.CategoryID=Categories.CategoryID LEFT OUTER JOIN PublishHouses ") _T("On Books.CategoryID=PublishHouses.PublishHouseID ")
-
Using the class "A set of ADO classes - version 2.20 By Carlos Antollini" Trying to delete the current record set with the following code if (pRs->IsOpen()) { if (!pRs->IsEOF()) pRs->Delete(); } the application craches with "unhandled exception in App.exe (kernel32.dll) 0xe06d7363:Microsodt C++ Exception. What seems to be worng ? sdancer