Read-only database problem? 
Author Message
 Read-only database problem?

Quote:

>I am joining more than one Paradox table with a TQuery and then displaying the
>resultset in a TDBGrid.  Because I am joining two tables (and sorting the
>data) the resultset is read-only.  I get the user to update the data by having
>a second TQuery on the base table and entering data in a TMaskEdit field, then
>running an "UPDATE TABLE SET ... WHERE ..." to update the table.
>The problem is that after I updated the table with the second TQuery, I want
>the new results to display in the TDBGrid that queries the same table that was
>just updated (joined with other tables).  The only way I found  to do this was
>to close the TQuery that the TDBGrid uses and then open it again, but this
>causes the grid to go blank for a second or so (and the table isn't very big
>yet).  I have tried the Refresh method on the TQuery and TDBGrid, but this
>seem to do nothing even though the delphi help file states that: "The Refresh
>method rereads all records from the dataset. Use Refresh to be certain
>that data controls display the latest information from the dataset.".
>Does anyone have any ideas please?  Is there an easier way to allow the user
>to update data from a TQuery that doesn't provide updateable data?

The Refresh method of the TQuery does indeed not return the new, changed
field values. This is most likely due to the fact that this is local SQL
and will usually produce the intended results when the Refresh method is
applied like this in conjunction with remote SQL tables. But then, the data
set from the first TQuery would not be read-only, obviating the need for
the second TQuery for editing.

You can get around that flicker when closing the TQuery by using the
DisableControls and EnableControls methods:

  procedure TForm1.Button1Click(Sender: TObject);
  begin
    with Query1 do begin
      DisableControls;
      Close;
      Open;
      EnableControls;
    end;
  end;

But the closing and reopening of the TQuery will still cause the record
pointer to return to the top of the result set. This could be overcome by
remembering to a memory variable a key field value (before closing the
TQuery and after the call to DisableCotrols), and then using that value to
find the row again (after reopning the TQuery but before the call to
EnableControls).

**************************************************************************
Steve Koterski
Local InterBase Server Technical Support
Borland International, Inc.



Mon, 16 Mar 1998 03:00:00 GMT  
 Read-only database problem?
I am joining more than one Paradox table with a TQuery and then displaying the
resultset in a TDBGrid.  Because I am joining two tables (and sorting the
data) the resultset is read-only.  I get the user to update the data by having
a second TQuery on the base table and entering data in a TMaskEdit field, then
running an "UPDATE TABLE SET ... WHERE ..." to update the table.

The problem is that after I updated the table with the second TQuery, I want
the new results to display in the TDBGrid that queries the same table that was
just updated (joined with other tables).  The only way I found  to do this was
to close the TQuery that the TDBGrid uses and then open it again, but this
causes the grid to go blank for a second or so (and the table isn't very big
yet).  I have tried the Refresh method on the TQuery and TDBGrid, but this
seem to do nothing even though the Delphi help file states that: "The Refresh
method rereads all records from the dataset. Use Refresh to be certain
that data controls display the latest information from the dataset.".

Does anyone have any ideas please?  Is there an easier way to allow the user
to update data from a TQuery that doesn't provide updateable data?

Thanks in advance for the help.



Mon, 16 Mar 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Read Only Database Problem

2. Newbie: How do I read a database?

3. SQL databases - reading and writing: Delphi 1.02

4. Paradox database on Read-only drive

5. Access V1.1 - Can Delphi read these databases?

6. Reading MS-Access database w/ delphi

7. SQL search on Calculated field with read only database

8. Read/Write WideString into a Database

9. Read MS SQL Server database Transaction log ?

10. Access Paradox Database in a readonly network directory

11. reading struc-info of a DBaseIII+ database

12. Reading and creating databases

 

 
Powered by phpBB® Forum Software