Board index » delphi » ADOQuery how work cashed update like TQuery

ADOQuery how work cashed update like TQuery

Use a lock type of BatchUpdate.

Make changes to several rows then Apply Batch Update. Also see Batch
Filters.

You may have problems with disconnected recordsets and Shape Provider but
otherwise works well.

Experiment with http://www.adoanywhere.com/download/aaBrowse2_7.zip

--
Michael Collier Bsc (Hons) Comp Sci
ADO Support Tools.
Fully Working 15-Day Trial...
http://www.adoanywhere.com/download/aaBrowse2_7.zip
Home Page
http://www.adoanywhere.com

Quote
"Alfred Obermayer" <a.oberma...@cdnet.at> wrote in message

news:3c692ced_1@dnews...
Quote
> the following code work very fine if cashedupdates:=true on a TQuery
> While not Query1.EOF do
>   begin
>   Query1.Edit;
>   Query1.FieldByName('isTIFF').asString := '1';
>   Query1.Post;
>   Query1.next;
>   end;

> but can any one give me some rows how work it with a TADOQuery ?

> many thank's in advance
> a.obermayer

 

Re:ADOQuery how work cashed update like TQuery


the following code work very fine if cashedupdates:=true on a TQuery
While not Query1.EOF do
  begin
  Query1.Edit;
  Query1.FieldByName('isTIFF').asString := '1';
  Query1.Post;
  Query1.next;
  end;

but can any one give me some rows how work it with a TADOQuery ?

many thank's in advance
a.obermayer

Re:ADOQuery how work cashed update like TQuery


I can find follwing LockType on my ADOQuery

ltBatchOptimistic, ltOptimisc, ltPessimistic, ltReadOnly and ltUnspecified
but not your mentioned "BatchUpdate" !

how can I set TADOQuery to this property.
I have tested with "ltBatchOptimistic" but without a positive result.

can you give me more hint's

a.obermayer

Re:ADOQuery how work cashed update like TQuery


     If you have D5 Ent or D6, you would probably better off
using ClientDataSets for Cached Updates.

Sunil

Quote
"Alfred Obermayer" <a.oberma...@cdnet.at> wrote:
>the following code work very fine if cashedupdates:=true on a TQuery
>While not Query1.EOF do
>  begin
>  Query1.Edit;
>  Query1.FieldByName('isTIFF').asString := '1';
>  Query1.Post;
>  Query1.next;
>  end;

>but can any one give me some rows how work it with a TADOQuery ?

>many thank's in advance
>a.obermayer

Re:ADOQuery how work cashed update like TQuery


With LockType = ltBatchOptimistic, do all your edits/posts, then call
UpdateBatch to write the changes to the database.

Andy Mackie.

Re:ADOQuery how work cashed update like TQuery


Quote
Andy wrote:  With LockType = ltBatchOptimistic, do all your edits/posts,

then call

Hi Andy,
you are sure it work together with TADOQuery ?
I gat a exception > the field 'isTIFF' can not be changed !, although the
LockType=ltBatchOptimistic

I use D5 with ADOExpress.
On the form I have a ADOConnection and ADOQuery.
With button1 I selct 10 records from Kunden table

With ADOQuery1 do
  begin
  close;
  Sql.Clear;
  Sql.Add('Select top 10 Name,  0 isTIFF');
  Sql.Add('From Kunden');
  open;
  end;

With button2 I start change field isTIFF
While not ADOQuery1.EOF do
  begin
  ADOQuery1.Edit;
  ADOQuery1.FieldByName('isTIFF').asInteger := 1;
  ADOQuery1.next;
  end;
  ADOQuery1.UpdateBatch;

You have a idea whats wrong ?

alfred.

Re:ADOQuery how work cashed update like TQuery


Quote
Alfred Obermayer <a.oberma...@cdnet.at> wrote in message

news:3c6a2c03$1_1@dnews...

Quote
>   Sql.Add('Select top 10 Name,  0 isTIFF');
>   Sql.Add('From Kunden');
>   open;
...
>   ADOQuery1.Edit;
>   ADOQuery1.FieldByName('isTIFF').asInteger := 1;
>   ADOQuery1.next;
>   end;
>   ADOQuery1.UpdateBatch;

UpdateBatch does work with ADOQuery. The problem is your select statement -
is that 0 supposed to be in front of isTIFF ? Should 'Select top 10 Name,  0
isTIFF' really be 'Select top 10 Name,  isTIFF' ? Your query as is doesn't
return the isTIFF column from the database, it's returning the constant
value of 0 and this can't be updated

Andy Mackie.

Re:ADOQuery how work cashed update like TQuery


Quote
Andy wrote: > UpdateBatch does work with ADOQuery.

Hi Andy,
thank's for your answer.
You have a idea how mast look a row for the TADOQuery to SQL7, so it
crate a editable empty row on queryresult.
Sql.Add('Select top 10 Name, ?????); <<<==== ?

many thank's
for your help
alfred

Re:ADOQuery how work cashed update like TQuery


Quote
Alfred Obermayer <a.oberma...@cdnet.at> wrote in message

news:3c6a681f_2@dnews...

Quote
> Andy wrote: > UpdateBatch does work with ADOQuery.

> Hi Andy,
> thank's for your answer.
> You have a idea how mast look a row for the TADOQuery to SQL7, so it
> crate a editable empty row on queryresult.
> Sql.Add('Select top 10 Name, ?????); <<<==== ?

I'm not sure what you are asking. Does isTIFF represent a column that exists
in the database ? If so, it's just 'Select top 10 Name,  isTIFF'. Or are you
saying that isTIFF doesn't exist in the database, but you want isTIFF to be
an in-memory calculated field that can also be updated ?

Andy Mackie.

Re:ADOQuery how work cashed update like TQuery


Quote
>>Andy wrote: I'm not sure what you are asking. Does isTIFF represent a

column that exists

Quote
>isTIFF doesn't exist in the database. After select I fill this extrafield

with a value (0 or 1)
Quote
>I scan a directory and check if a tiff-image is availabled in the directory

or no, If availabled the value =1

Quote
>hope this help.

Alfred.

Re:ADOQuery how work cashed update like TQuery


Quote
Alfred Obermayer <a.oberma...@cdnet.at> wrote in message

news:3c6a90d4_2@dnews...

Quote
> >>Andy wrote: I'm not sure what you are asking. Does isTIFF represent a
> column that exists

> >isTIFF doesn't exist in the database. After select I fill this extrafield
> with a value (0 or 1)
> >I scan a directory and check if a tiff-image is availabled in the
directory
> or no, If availabled the value =1
> >hope this help.

In that case, it sounds like you need to be using a calculated field and
setting it's value in the OnCalcFields event.

Andy Mackie.

Re:ADOQuery how work cashed update like TQuery


Quote
Andy wrote:
>> In that case, it sounds like you need to be using a calculated field and
>> setting it's value in the OnCalcFields event.

Hi Andi,
exact,  but how can I create a extra field by defination my first query ==>>
Sql.Add('Select top 10 Name, ?????);
if I change the fieldvalue by OnCalcFields or after first query done with a
seperate operation is not the question.
essential at first is, a need a Fied in the queryresult that deal with a
furthermore operation.

I ask you for some understanding, but my english is not so perfect for a
excellent expressing but I hope we can
find out a way for a succesful solution.

many thank's in advance
Alfred.

Re:ADOQuery how work cashed update like TQuery


Quote
Alfred Obermayer <a.oberma...@cdnet.at> wrote in message

news:3c6b6bce$1_2@dnews...

Quote
> Andy wrote:
> >> In that case, it sounds like you need to be using a calculated field
and
> >> setting it's value in the OnCalcFields event.

> Hi Andi,
> exact,  but how can I create a extra field by defination my first query
==>>
> Sql.Add('Select top 10 Name, ?????);
> if I change the fieldvalue by OnCalcFields or after first query done with
a
> seperate operation is not the question.
> essential at first is, a need a Fied in the queryresult that deal with a
> furthermore operation.

Rather than setting the SQL at run-time, it might be easiest to set the SQL
property at design time to 'Select top 10 Name From Kunden', then use the
Fields Editor (right-click the ADOQuery, choose Fields Editor) to add all
fields (right-click the fields editor, choose Add all fields), then add a
calculated field (right-click the fields editor, choose New field then
create a field of type Calculated). If you really want to add a calculated
field at run-time, this might help:

http://groups.google.com/groups?hl=en&threadm=8d40jto8jccf6jjmkef0725...
4v62%404ax.com&rnum=1

Andy Mackie.

Other Threads