Subject | RE: [firebird-support] FB, Delphi 7, IB components and transactions |
---|---|
Author | Diego Barros |
Post date | 2005-01-13T21:54:37Z |
On Thursday, January 13, 2005, at 10:59PM, Alan McDonald <alan@...> wrote:
Thanks for the reply.
Even still, if I don't commit it, and the application crashes at any stage after doing an ExecSQL to insert a new record, that record will be there when I re-run the application after a crash? It doesn't mean the record is not inserted in to the database?
BTW this is a single user application.
Cheers,
Diego
>Hi Alan,
>> Hi all,
>>
>> I am a newbie when it comes to transactions, so please excuse my
>> ignorance when it comes to transactions.
>>
>> I am using FB 1.5.2, with Delphi 7 and the IB components. My
>> question is, why when I insert a record into a table don't I see
>> it in another running program?
>>
>> I have a small test application with a query which selects a
>> count of records from a table. On a form I show this number when
>> I click the Refresh button. I have another button which inserts a
>> new record into the table. So my form has the following components:
>>
>> IBQuery1 - which does a SELECT COUNT(*) on the table
>> IBQuery2 - which inserts a record
>> IBDatabase - used by both queries
>> IBTransaction - used by the IBQuery1, IBQuery2 and IBDatabase components
>>
>> When I click the Refresh button I execute the following code:
>>
>> IBQuery1.Close();
>> IBQuery1.Open();
>>
>> When I click the Insert button I execute the following code:
>>
>> IBQuery2.ExecSQL;
>>
>> I then run two copies of this test program. I insert a record in
>> one instance of the program, click refresh and I see the record
>> count increase. I click Refresh on the other instance of the
>> application and the count does not change.
>>
>> Can this behavior be changed? I changed the transaction component
>> to be read-commited, but that did not change the behavior. Maybe
>> this is all about a different mindset and how one works with
>> IB/FB? Are there any articles which talk about this? Maybe I need
>> to try other components which work differently from a programming
>> point of view?
>>
>> Any help or tips would be greatly appreciated by the FB newbie.
>>
>> Regards,
>> Diego
>
>you need to commit the transaction to see the change in another application.
>Instead of
>Query.Close
>Query.Open
>Use IB_Connection.DefaultTransaction.Refresh(true);
>
>Alan
Thanks for the reply.
Even still, if I don't commit it, and the application crashes at any stage after doing an ExecSQL to insert a new record, that record will be there when I re-run the application after a crash? It doesn't mean the record is not inserted in to the database?
BTW this is a single user application.
Cheers,
Diego