Board index » delphi » dbgrid --> TQuery problem

dbgrid --> TQuery problem

I have a dbgrid linked to a datasource linked to a  table.  The table is
linked to a data source which is linked to a TQuery object. like this:

dbgrid ---> Tdatasoource----->TTable ---> Tdatasource ----> TQuery

My end objective is to be able to view rows of data off my database based on
view criteria, but give the end-user the ability to delete a selected row.
The TTable object permits the delete function. My problem is the TTable
object does not update its rows when the TQuery object's select  statement
changes. Instead the TTable object maintains all rows in the database---as
though the Tquery select were "Select * from THETABLE"

I've tried different combinations of datasource connections, but found the
above to at least allow proper deletion of selected records, The only
problem is I need to have the view change with the change of the SQL
statement.

Help.

Thanks...

Will
Please reply to : wflem...@inet-1.com

 

Re:dbgrid --> TQuery problem


Will and Linda Fleming wrote:

Quote

> I have a dbgrid linked to a datasource linked to a  table.  The table is
> linked to a data source which is linked to a TQuery object. like this:

> dbgrid ---> Tdatasoource----->TTable ---> Tdatasource ----> TQuery

> My end objective is to be able to view rows of data off my database based on
> view criteria, but give the end-user the ability to delete a selected row.
> The TTable object permits the delete function. My problem is the TTable
> object does not update its rows when the TQuery object's select  statement
> changes. Instead the TTable object maintains all rows in the database---as
> though the Tquery select were "Select * from THETABLE"

You do not need the TQuery or the second datasource. Both the TTable and
the TQuery are objects that encapsulate a database cursor. That means :
each will create a way to update the underlying table.

Use indexes and the SetRange method to limit what you see in the grid.
Use the delete  method to delete the current record in the underlying
table.

HTH

Other Threads