Board index » cppbuilder » Using ADO to bypass concurrency checks in a TADOQuery

Using ADO to bypass concurrency checks in a TADOQuery


2007-04-10 06:57:51 AM
cppbuilder8
Using BDS2006, TADOQuery, MSSQL 2005 Express, MS SQLOLEDB.1 driver
I'm trying to see if I can make a TADOQuery to not get a concurrency
error when I:
1) Select single row in App A
2) App B updates same row
3) App A then updates same row via TADOQuery::Edit() and ::Post()
methods, but gets concurrency error (specifically "Row cannot be located
for updating. Some values may have been changed since it was last read")
Ignoring the general issue of should I be doing this or not, does anyone
know of a way to make App A still be able to overwrite the changes
posted by App B without making App A reestablish position (i.e., issue
another select statement)?
I've been playing around with the connection's IsolationLevel, the
query's CursorType and LockType, but no luck.
Any suggestions?
Thanks,
Paul Rodden
 
 

Re:Using ADO to bypass concurrency checks in a TADOQuery

Try to set Recordset.Properties['Update Criteria'].Value to adCriteriaKey
( = 0). After that it should locate row by key, not by all columns - be sure
that you have PK.
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"PaulR" < XXXX@XXXXX.COM >???????/???????? ? ????????
?????????: news:461ac4e3$ XXXX@XXXXX.COM ...
Quote
Using BDS2006, TADOQuery, MSSQL 2005 Express, MS SQLOLEDB.1 driver

I'm trying to see if I can make a TADOQuery to not get a concurrency error
when I:

1) Select single row in App A
2) App B updates same row
3) App A then updates same row via TADOQuery::Edit() and ::Post() methods,
but gets concurrency error (specifically "Row cannot be located for
updating. Some values may have been changed since it was last read")

Ignoring the general issue of should I be doing this or not, does anyone
know of a way to make App A still be able to overwrite the changes posted
by App B without making App A reestablish position (i.e., issue another
select statement)?

I've been playing around with the connection's IsolationLevel, the query's
CursorType and LockType, but no luck.

Any suggestions?

Thanks,
Paul Rodden

 

Re:Using ADO to bypass concurrency checks in a TADOQuery

Vassiliev V. V. wrote:
Quote
Try to set Recordset.Properties['Update Criteria'].Value to adCriteriaKey
( = 0). After that it should locate row by key, not by all columns - be sure
that you have PK.
Hi, thanks for your suggestion. I'm working in C++, and I'm having a
hard time figuring out how to implement this in C++. The IDE shows the
[] being overridden, but I can't figure out how to pass in the property
name. Doing Properties["Update Criteria"] doesn't work.
Any suggestions?
Thanks,
Paul Rodden
 

{smallsort}

Re:Using ADO to bypass concurrency checks in a TADOQuery

It was Delphi code. In C++ it is:
#include <comobj.hpp>
enum ADCPROP_UPDATECRITERIA_ENUM
{ adCriteriaKey = 0,
adCriteriaAllCols = 1,
adCriteriaUpdCols = 2,
adCriteriaTimeStamp = 3
} ADCPROP_UPDATECRITERIA_ENUM;
If you use C++ Builder 6 you may need to fix its bug with:
namespace System
{
void __fastcall CheckSafecallResult(HRESULT hr)
{
OleCheck(hr);
}
}
Then:
ADOQuery1->Active = true;
ADOQuery1->Recordset->Properties->Item[WideString("Update
Criteria")]->Value = adCriteriaKey;
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"PaulR" < XXXX@XXXXX.COM >???????/???????? ? ????????
?????????: news:461bc6f0$ XXXX@XXXXX.COM ...
Quote
Vassiliev V. V. wrote:
>Try to set Recordset.Properties['Update Criteria'].Value to adCriteriaKey
>( = 0). After that it should locate row by key, not by all columns - be
>sure that you have PK.

Hi, thanks for your suggestion. I'm working in C++, and I'm having a hard
time figuring out how to implement this in C++. The IDE shows the []
being overridden, but I can't figure out how to pass in the property name.
Doing Properties["Update Criteria"] doesn't work.

Any suggestions?

Thanks,
Paul Rodden
 

Re:Using ADO to bypass concurrency checks in a TADOQuery

Vassiliev V. V. wrote:
Quote
It was Delphi code. In C++ it is:
That did it, and setting the "Update Criteria" property did what I wanted.
Thank you very much!
Paul Rodden