On Wednesday 16 June 2010 20:10:09 Burkhard Carstens wrote: This is for MSEide+MSEgui:
> > chapter 1 - Database programming > > First, I created a desktop app to play with the database. All the DB > components on a DataModule and some DBGrid, DBNavigator on a form. > * First problem: > Data changes in the grid don't get to the database. > * Solution: > in SQLQueryTimes.OnAfterPost add: > SQLQueryTimes.ApplyUpdates; > SQLTransactionTimes.CommitRetaining; > Activate tmsesqlquery.controller.options dso_autoapply and dso_autocommitret. > * Next problem: > When doing "insert, post, edit (the inserted row), post" the data > doesn't get to DB. > * Found reason: > The primary key is an auto-increment. It is added by postgres when > inserting the record, but not reported back. Therefore, the following > Update statement uses (probably?) "UPDATE .. WHERE times_id = NULL .." > while times_id actually got a non-NULL value in the DB. So the update > statement does nothing, not even reporting an error. > * Solution: > none. According to http://bugs.freepascal.org/view.php?id=16076 this is > not yet implemented. Use a sequence generator in the DB in order to build the primary key value. Place a tsequencelink (tab DBf) into the datamodule, select database datasource and datafield, fill in the 'sequencename' property. > > * Next Problem: > The "projects" are stored in a second table with id, name and some other > info. Now I'd like to see (and deal with) the projects name instead of > its ID in the times_grid. Some keywords came to memory: "Master/ > Detail", "Lookup" and "JOIN" .. [...] > > * Solution: > none, at least not the way I intended. Seems like DBGrid is not (yet) > able to offer a LookupCombo in a cell like Delphi does. (After I found > out, I also saw the related bug report .. ) I got something working > with a separate DBLookupList next to the grid .. > Use tdbwidgetgrid (tab DBe), place a tdbenumeditdb into the lookup column (tab DBe). Alternative for better performance with very big lookup datasets: tdbenumeditlb (tab DBe) and tdblookupbuffer (tab DB). Martin _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal