Re: Delphi7/ADO/SQL Server 2000 TDBGrid problem
From: Morpheus (morpheusNOPSAM_at_redpoint.co.za)
Date: 06/18/04
- Previous message: Martijn Tonies: "MS SQL and the Cancel on RecordSet/Command"
- In reply to: Robert Carrington: "Delphi7/ADO/SQL Server 2000 TDBGrid problem"
- Next in thread: Robert Carrington: "Re: Delphi7/ADO/SQL Server 2000 TDBGrid problem"
- Reply: Robert Carrington: "Re: Delphi7/ADO/SQL Server 2000 TDBGrid problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 18 Jun 2004 17:41:58 +0200
Hi Robert,
It's uncanny. I have pretty much the same setup in an app. I am working on.
I use this approach to edit what I call simple system tables. Thye are
typically tables with two columns, a unique autoincrement ID column, and a
column named Description. I have implemented the logic you allude to with no
problem.
I have a TDBGrid on the left which retrieves a dataset from a view in the
SQL DB. This view pulls out table names from systables and the Table object
comments field from sysproperties, in which I define the table name that the
user sees.
When the user scrolls in this list, a tdbgrid to the right has its
datasource.dataset connected to the appropriate TADODataset component on my
data module. I've never had the problem that you refer to. I do not even
close and re-open tables when I am switching tables, and the record pointers
remain where they were when I last edited the table. The possible difference
is that I do not edit data in the grid. Because all of the editable columns
are called Description, I can safely make the grid read-only, and edit the
selected row in a DBEdit. Works like a charm. My grid is therefore read
only, and the Options set are:
dgEditing=False
dgRowSelect=True
dgAlwaysShowSelection=True
Maybe this will help.
Incidentally, I detect the move in the grid listing the tables in either the
oncellclick event or in the onkeyup event, or in the OnMouseDown event,
although I still have not gotten it to properly detect a right mosue button
click.
Hope this might be of help.
Regards,
Morpheus
"Robert Carrington" <rcarrington@ice-sys.co.uk> wrote in message
news:40d04d0b@newsgroups.borland.com...
> I have 1 TDBGrid component and multiple TADOQuery objects that can be
> connected to it.
>
> Depending on where grid is accessed from a different query is connected to
> it. These queries are always open in the background regardless.
>
> The problem is that sometimes when trying to select a row in the grid it
> actually selects a completely different row. 2 indicators are shown on
the
> indicator column as well. These can only be got rid of by selecting the
row
> that was initially selected.
>
> This usually happens after the TDBGrid.DataSource.DataSet has been swapped
> several times and then returns to a dataset that has been open in the
past.
>
> Is this a bug that anyone else has come across? I agree that it is not a
> particularly good method of doing things but it is still doing something
> that is apparently allowed by Delphi and it is not throwing any errors.
> Also there should be no possible way for a row other than the one you
click
> on to be selected. I would be interested if anyone else has/is able to
> replicate this as I have not seen anything about this on the net.
>
> I have tried various methods of refreshing/repainting and cannot get
> anything to work.
>
> NOTE:
> 1. I cannot just rewrite the code as it would have too large an impact on
> the rest of the program.
> 2. I cannot just close the query and reopen it as I wish to retain the
> position in the query. ).
>
>
- Previous message: Martijn Tonies: "MS SQL and the Cancel on RecordSet/Command"
- In reply to: Robert Carrington: "Delphi7/ADO/SQL Server 2000 TDBGrid problem"
- Next in thread: Robert Carrington: "Re: Delphi7/ADO/SQL Server 2000 TDBGrid problem"
- Reply: Robert Carrington: "Re: Delphi7/ADO/SQL Server 2000 TDBGrid problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]