Thread View: borland.public.cppbuilder.database.ado
5 messages
5 total messages
Started by PaulR
Mon, 09 Apr 2007 22:57
Using ADO to bypass concurrency checks in a TADOQuery
Author: PaulR
Date: Mon, 09 Apr 2007 22:57
Date: Mon, 09 Apr 2007 22:57
23 lines
1658 bytes
1658 bytes
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
Author: Vassiliev V. V.
Date: Tue, 10 Apr 2007 14:24
Date: Tue, 10 Apr 2007 14:24
39 lines
2466 bytes
2466 bytes
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. http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + ADO.Net http://www.oledbdirect.com - The fastest way to access MS SQL Server, MS Jet (Access) and Interbase (through OLEDB) "PaulR" <nospam_prodden@jwscorp.com_nospam> ???????/???????? ? ???????? ?????????: news:461ac4e3$1@newsgroups.borland.com... > 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
Author: PaulR
Date: Tue, 10 Apr 2007 17:18
Date: Tue, 10 Apr 2007 17:18
14 lines
1536 bytes
1536 bytes
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
Author: Vassiliev V. V.
Date: Tue, 10 Apr 2007 20:01
Date: Tue, 10 Apr 2007 20:01
56 lines
2717 bytes
2717 bytes
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.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"PaulR" <nospam_prodden@jwscorp.com_nospam> ???????/???????? ? ????????
?????????: news:461bc6f0$1@newsgroups.borland.com...
> 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
Author: PaulR
Date: Tue, 10 Apr 2007 22:28
Date: Tue, 10 Apr 2007 22:28
8 lines
1329 bytes
1329 bytes
Vassiliev V. V. wrote: > 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads