On Wed, 12 Dec 2007, Graeme Geldenhuys wrote:

> On 12/12/2007, Joost van der Sluis <[EMAIL PROTECTED]> wrote:
> >
> > > Step 2:
> > You don't need to do this. It is used when the TIBConnection tries to
> > execute some sql-statements itself. If has to know which transaction it
> > should use. You have to see this as the 'default transaction'. If you do
> > TIBConnection.ExecuteDirect, this transaction is used. This transaction
> > is also used when you use ApplyUpdates.
> >
> 
> <....snip....>
> 
> > > Step 5b: (optional)
> > > ======
> > > TSQLQuery  ->  TDatasource via the 'DataSource' property.  It can be
> > > done, but wasn't needed to get my example project to work. Not sure
> > > what's the rules about this one.
> >
> > I've been mistaken about this one more then once. Also my collegues had
> > problems with this.
> > iirc it's renamed to something else in recent versions. What it does is
> > handling the master-detail relationships.
> 
> 
> I have to beg to differ on both counts!  They are both required, see below.
> 
> I could send you my project if it might help.
> 
> 
> As for Step 5. Well in my simple example I have a query: "Select * from 
> users".
> No master-detail relationship there! Yet if I try to set the
> TSQLQuery.Active = True I get a "Database not assigned!" error.
> Assign the "Database" property to IBConnection1 and try Active = True again.
> 
> This time I get the following error:  "Transaction of connection not
> set".  Now I go to the IBConnection1 and set the Transaction (doubly
> link madness) and no I'm not trying to execute anything directly via
> the IBConnection.  Go back to SQLQuery and set Active = True.  Now
> everything works and I get results in the DBGrid.
> 
> So bottom line - all the steps from my first email *are* required to
> get results in a DBGrid.

In that case you represented step 5 wrongly: There you need 
DataSource.Dataset -> TSQLQuery.

In short, assume the following components:

DB : TSQLConnection descendent.
TR : TSQLTransaction;
Q : TSQLQuery;
DS : TDataSource;
G : TDBGrid;

Then these are the steps:

1. TR.Database -> DB
2. DB.DefaultTransaction -> TR // Should be automatic in future.
3. Q.Transaction -> TR
4. Q.Database->DB // Should be automatic in future.
5. DS.Dataset->Q;
6. G.DataSource->DS;

If all works as I want it, this should be reduced to 4 steps for the default 
cases,
and steps 1 and 2 can be reversed if so desired, and steps 3 and 4 also.

Michael.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to