Why DB Pessimistic lock doesn't work

I have code that changes a field in pessimistic lock.
I'm loading two instances of visual C++ with the same code.
in theory when I'm trying to change a field in the same record, I'm supposed
to get an exception, for some reason it doesn't work.
does anyone knows does this happen ?

The code is like this:

m_pDBConn->ConnectionString = _bstr_t( L"DRIVER={Microsoft Access Driver (*.mdb)};"
_bstr_t bsEmpty = L"";
m_pDBConn->Open( bsEmpty, bsEmpty, bsEmpty, -1 );
hr = m_pRS.CreateInstance(__uuidof(Recordset));
m_pRS->PutRefActiveConnection( m_pDBConn );
m_pTempRS->Open("SELECT * FROM MyTable WHERE ID = 1", vtMissing, adOpenKeyset, adLockPessimistic, adCmdText);
  m_pRS->Fields->Item["OneField"]->Value =  123;
catch (_com_error&)
  cout << "why am I'm not here ??? "<< endl;
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would assume the exception is thrown when calling recordset Update.

Maybe for a dynamic Recordset it is different.

Regards, Alex

MagicianHAuthor Commented:
If you have a code sample that is working, maybe I coulds copy & try it out...
MagicianHAuthor Commented:
I'm interested in the answer, but nobody answers me...
You asked for a code sample. Unfortunately, i didn't use ADO myself, so i couldn't provide a sample.

However, i'am a pretty experienced database programmer. So, i wouldn't expect 'Pessimistic Locking' is throwing an exception when editing members of the recordset

   m_pRS->Fields->Item["OneField"]->Value =  123; // It's a simple integer assignment

- as that is C++ and the database or recordset isn't involved .

I would expect an exception when you are trying to store while another client had updated in the meantime.

Maybe you should check that suggestion using your own code.

Regards, Alex

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.