Board index » delphi » Disabling insert in a DBGrid + TQuery refresh problems

Disabling insert in a DBGrid + TQuery refresh problems

Hi all,

How can I disable the inserting mode of a DBGrid, if I want to enable
modifying? The dataset is a TTable.

The another question is: I modify a table with the TTable.BatchMove
method, then close that table. I have a TQuery which depends on the
underlying datafile, but I call the TQuery.Refresh for nothing; the
only way to make it notice the change is to Close and Open it. I fear
that it takes more time than a (working) Refresh. Do am I make
something wrong?

Ah, yes, and then another question: am I right that this BatchMove
works only if the tables' field-structure is the same? The help
doesn't say anything about it... :(

Thx:
Circum

 __  @
/  \    _   _                                           Engrd Ferenc
l    | ( \ /  | | (\/)                      mailto:s-f...@kkt.sote.hu
\__/ | |   \_ \_/ I  I                    http://pons.sote.hu/~s-fery

 

Re:Disabling insert in a DBGrid + TQuery refresh problems


1. about disable of insert into DBGrid:
- you can in onnewrecord call Abort method
or
- download a freeware TSMDBGrid component from my site with such posibility
and more additional features

2. about TQuery.Refresh - for TQuery the Refresh method is not work and
really you must use a Close/Open

3. for TBatchMove component you can define a field list - view a
MappingFields property

--
With best regards, Mike Shkolnik.
E-Mail: mshkol...@rs-ukraine.kiev.ua
        mshkol...@yahoo.com
WEB: http://www.geocities.com/SiliconValley/Grid/3989
          http://www.geocities.com/mshkolnik

Engard Ferenc ??? a ???? ...
Hi all,

How can I disable the inserting mode of a DBGrid, if I want to enable
modifying? The dataset is a TTable.

The another question is: I modify a table with the TTable.BatchMove
method, then close that table. I have a TQuery which depends on the
underlying datafile, but I call the TQuery.Refresh for nothing; the
only way to make it notice the change is to Close and Open it. I fear
that it takes more time than a (working) Refresh. Do am I make
something wrong?

Ah, yes, and then another question: am I right that this BatchMove
works only if the tables' field-structure is the same? The help
doesn't say anything about it... :(

Thx:
Circum

__  @
/  \    _   _                                           Engrd Ferenc
l    | ( \ /  | | (\/)                      mailto:s-f...@kkt.sote.hu
\__/ | |   \_ \_/ I  I                    http://pons.sote.hu/~s-fery

Re:Disabling insert in a DBGrid + TQuery refresh problems


Quote
Engard Ferenc wrote:

> How can I disable the inserting mode of a DBGrid, if I want to enable
> modifying? The dataset is a TTable.

If your TTable is Items and your DBGrid is MyGrid, put this in the
Items's BeforeInsert event:

procedure TForm1.ItemsBeforeInsert(DataSet: TDataset);
begin
  if ActiveControl =MyGrid
  then Abort;

Quote
> I have a TQuery which depends on the
> underlying datafile, but I call the TQuery.Refresh for nothing; the
> only way to make it notice the change is to Close and Open it.

That's the way to do it with Querys, Close/Open.  Refresh does not
work there.

Markku Nevalainen

Re:Disabling insert in a DBGrid + TQuery refresh problems


On Sun, 26 Sep 1999 18:19:08 GMT, Engard Ferenc <f...@pons.sote.hu>
wrote:

Quote
>Hi all,

>How can I disable the inserting mode of a DBGrid, if I want to enable
>modifying? The dataset is a TTable.

Use a TTable.OnBeforeInsert event handler and simply call
Sysutils.Abort.  This raises a silent exception which will prevent
insertions.
Quote

>The another question is: I modify a table with the TTable.BatchMove
>method, then close that table. I have a TQuery which depends on the
>underlying datafile, but I call the TQuery.Refresh for nothing; the
>only way to make it notice the change is to Close and Open it. I fear
>that it takes more time than a (working) Refresh. Do am I make
>something wrong?

I thought Refresh simply calls Close and Open, but I could be wrong.
Quote

>Ah, yes, and then another question: am I right that this BatchMove
>works only if the tables' field-structure is the same? The help
>doesn't say anything about it... :(

You must make sure that the fields are compatible and values inserted
don't go out of the range of the field.

Paul
aspsc...@tcp.co.uk
^^ remove 'as' anti spam prefix to reply

Other Threads