Quote
Bryan Keller <br...@wco.com> wrote:
>I called Borland tech support this morning and confirmed a problem when using linked
>queries with MS SQL Server. If the master query is opened after the detail query has been
>opened, the master result set will be incomplete. This happens in both Delphi 1 and Delphi 2
>using SQL Links. To get around this, I wrote a component descended from TQuery and created a
>custom 'Open' method. This routine closes any open detail queries before opening the query,
>then reopens any detail queries. It works great.
Unfortunatly, this multiple query bug is not limited to master /
detail queries, so your fix may not work in some cases. Try this
example with two totally unrelated queries:
1) Place two TQuery, TDatasource, and TDBGrid components on a form,
hooking up Query1 with Datasource1 and Datasource 1 with DBGrid1; then
Query2 with Datasource2 and Datasource2 with DBGrid2
2) Query1's SQL might look like this: "select * from customers", and
Query2's SQL might look like this: "select * from employees".
3) Place three buttons on the form called Button1, Button2, and
Button3
4) On Button1's OnClick event, open Query1 then Query2.
5) On Button2's OnClick event, close Query1 then reopen Query1.
6) On Button 3's OnClick event, close Query2.
7) Run the program, then click button's 1, 2, and 3 in sequence. The
result is that DBGrid1 will not scroll past the last visible row in
the grid.
There is a work around. Try adding a fourth button that retrieves
Query1.RecordCount. It will correct the problem, but this causes all
rows of the query to be fetched (a major problem in a WAN
environment).
Without the record count / fetch, the only way to keep your
application from looking VERY undependable is to close any query (on
the same database connection) that was opened after the query you are
about to refresh before refreshing it.