BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using ADO to bypass concurrency checks in a TADOQuery

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO)
View previous topic :: View next topic  
Author Message
PaulR
Guest





PostPosted: Tue Apr 10, 2007 3:57 am    Post subject: Using ADO to bypass concurrency checks in a TADOQuery Reply with 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
Back to top
Vassiliev V. V.
Guest





PostPosted: Tue Apr 10, 2007 7:24 pm    Post subject: Re: Using ADO to bypass concurrency checks in a TADOQuery Reply with 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.

//------------------------------------------
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 (AT) jwscorp (DOT) com_nospam> ???????/???????? ? ????????
?????????: news:461ac4e3$1 (AT) newsgroups (DOT) borland.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
Back to top
PaulR
Guest





PostPosted: Tue Apr 10, 2007 10:18 pm    Post subject: Re: Using ADO to bypass concurrency checks in a TADOQuery Reply with quote



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
Back to top
Vassiliev V. V.
Guest





PostPosted: Wed Apr 11, 2007 1:01 am    Post subject: Re: Using ADO to bypass concurrency checks in a TADOQuery Reply with quote

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 (AT) jwscorp (DOT) com_nospam> ???????/???????? ? ????????
?????????: news:461bc6f0$1 (AT) newsgroups (DOT) borland.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
Back to top
PaulR
Guest





PostPosted: Wed Apr 11, 2007 3:28 am    Post subject: Re: Using ADO to bypass concurrency checks in a TADOQuery Reply with quote

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.