Click here to Skip to main content
15,914,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Pin
toxcct13-Dec-05 6:29
toxcct13-Dec-05 6:29 
GeneralRe: Pin
peterchen13-Dec-05 8:02
peterchen13-Dec-05 8:02 
Question(ADO v2.20) pRs->Delete(); Crashes the application Pin
sdancer7513-Dec-05 5:04
sdancer7513-Dec-05 5:04 
AnswerRe: (ADO v2.20) pRs->Delete(); Crashes the application Pin
kdehairy13-Dec-05 6:28
kdehairy13-Dec-05 6:28 
GeneralRe: (ADO v2.20) pRs->Delete(); Crashes the application Pin
sdancer7513-Dec-05 6:49
sdancer7513-Dec-05 6:49 
AnswerRe: (ADO v2.20) pRs->Delete(); Crashes the application Pin
sdancer7513-Dec-05 21:39
sdancer7513-Dec-05 21:39 
GeneralRe: (ADO v2.20) pRs->Delete(); Crashes the application Pin
kdehairy15-Dec-05 2:28
kdehairy15-Dec-05 2:28 
GeneralRe: (ADO v2.20) pRs->Delete(); Crashes the application Pin
sdancer7516-Dec-05 5:07
sdancer7516-Dec-05 5:07 
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 ")
_T("ORDER BY title,author1,categoryDesc ASC");

if (pRs->Open(strSQL,CADORecordset::openQuery) )
{

pRs->SetAbsolutePosition (m_lAbsRecPosition);
}
else
{
pRs->Close();
delete pRs;

}


}
else
{
pAdoDb->Close();
delete pAdoDb;
}


}
catch (CADOException &e)
{
pRs->Close();
pAdoDb->Close();
delete pRs;
delete pAdoDb;

AfxMessageBox(_T("Data base error.");


m_bError=true;

m_bNext.EnableWindow (FALSE);
m_bPrevious.EnableWindow (FALSE);
m_bPrint.EnableWindow (FALSE);
m_bDelete.EnableWindow (FALSE);
m_bOk.EnableWindow (FALSE);
m_bUpdate.EnableWindow (FALSE);
m_bCreateNew.EnableWindow (FALSE);


}

}

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

sdancer
AnswerRe: (ADO v2.20) pRs->Delete(); Crashes the application Pin
sdancer7519-Dec-05 20:53
sdancer7519-Dec-05 20:53 
QuestionSome doubt on WM_PAINT and MemoryDC Pin
Sanjoy Sinharoy13-Dec-05 4:59
Sanjoy Sinharoy13-Dec-05 4:59 
AnswerRe: Some doubt on WM_PAINT and MemoryDC Pin
TheGreatAndPowerfulOz13-Dec-05 12:01
TheGreatAndPowerfulOz13-Dec-05 12:01 
QuestionRe: Some doubt on WM_PAINT and MemoryDC Pin
Sanjoy Sinharoy15-Dec-05 5:35
Sanjoy Sinharoy15-Dec-05 5:35 
QuestionHow can I create a PDF using Visual C++? Pin
DanYELL13-Dec-05 4:39
DanYELL13-Dec-05 4:39 
AnswerRe: How can I create a PDF using Visual C++? Pin
TheGreatAndPowerfulOz13-Dec-05 9:29
TheGreatAndPowerfulOz13-Dec-05 9:29 
AnswerRe: How can I create a PDF using Visual C++? Pin
ThatsAlok13-Dec-05 22:08
ThatsAlok13-Dec-05 22:08 
QuestionMemory leak detection Pin
the pink jedi13-Dec-05 4:26
the pink jedi13-Dec-05 4:26 
AnswerRe: Memory leak detection Pin
kdehairy13-Dec-05 6:35
kdehairy13-Dec-05 6:35 
AnswerRe: Memory leak detection Pin
ThatsAlok13-Dec-05 22:11
ThatsAlok13-Dec-05 22:11 
QuestionHow to get size of file ??????? Pin
VikramDelhi13-Dec-05 4:01
VikramDelhi13-Dec-05 4:01 
AnswerRe: How to get size of file ??????? Pin
Graham Bradshaw13-Dec-05 4:15
Graham Bradshaw13-Dec-05 4:15 
AnswerRe: How to get size of file ??????? Pin
Tim Smith13-Dec-05 4:26
Tim Smith13-Dec-05 4:26 
AnswerRe: How to get size of file ??????? Pin
ThatsAlok13-Dec-05 19:39
ThatsAlok13-Dec-05 19:39 
GeneralThanks a lot guys Pin
VikramDelhi14-Dec-05 3:39
VikramDelhi14-Dec-05 3:39 
QuestionReplacing open/save dialogs Pin
Krishnan V13-Dec-05 3:42
Krishnan V13-Dec-05 3:42 
QuestionRe: Replacing open/save dialogs Pin
David Crow13-Dec-05 3:57
David Crow13-Dec-05 3:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.