hi
i have searched alooooot for last 4 days..i have read allll the questions and articles and evry thing .. but i cant figure it out
my question is :
i have an mfc application connected to a sql server database via odbc
i want to lock a row when im editing it
its easy in many ereas .. even there is a fuction defined in crecordset named
setclockmode
that can has optimistic or pessimistic input parametere.. my ideal is that this function do the work for me with oessimistic parametere.. but when i run the app it says that my driver doesnt support pessimistic locking mode
and i have read that few odbc drivers support that(and i have no idea what does it mean!)
so..
i should lock the row..
i have tried the function executesql function i have tried transactions .. but yet cant understand what is my way .. and how they work..
here is my handler function on edit button:
void CPhoneView::OnBnClickededitcurrent()
{
if (m_pSet->m_pDatabase->BeginTrans())
{
if (m_pSet->CanUpdate() && !m_pSet->IsDeleted())
{
m_pSet->Edit();
UpdateData(true);
if (MessageBox(_T("are you sure that you want to edit this record?"), _T("Attention:"), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
if (m_pSet->Update())
MessageBox(_T("Row Edited\n"), _T("done:"), MB_ICONASTERISK);
else
MessageBox(_T("Row Cant be Edited\nor u didnt change any field to edit"), _T("Warning:"), MB_ICONWARNING);
}
else
{
m_pSet->CancelUpdate();
MessageBox(_T("Row Not Edited\n"), _T("done:"), MB_ICONASTERISK);
}
}
m_pSet->m_pDatabase->CommitTrans();
}
}
plzz help me to get rid of this terrible headache:(