?
Solved

Delphi (5) and Interbase: TIBDataSet updating

Posted on 2003-03-09
9
Medium Priority
?
456 Views
Last Modified: 2010-04-04
I'm a newbee in using Interbase with Delphi (5). I have set up a FireBird SS in a Linux box and it works fine. Link with D5 using TIBDataBase, TIBTransaction and TIBQuery in a program:OK. Just one thing is very curious using a TIBDataSet. Filling in the diffrent SQL phrases for insert,delete, modify, select and refresh is not a problem, bur what really is boring me is that I can't set up an SQL sentence to update my table. The TIBDataSet is made of:
InsertSQL:''
DeletSql:'delete from client where numero=:numero;' (numero is the primary key of the table)
ModifySQL:'update client set nomcomprime = :nomcomprime where numero = :old_numero";' (only one field is actually updated)
RefreshSQL='select * from client where numero=:old_numero;'
SelectSQL='select * from client where NOMCOMPRIME like 'C%';'

A grid is defined in the main form, the DataSource is linked to the DataSource in the DataForm, linked to the TIBDataSet. Basic processing is:
Show form: start transaction, open dataset. Data is correctly shown in the grid and corresponds to the selected subset.
A DBNavigator has been defined and linked to the same source the grid is linked.
Puxh update button, OK, data is updatable; field 'nomcomprime' is changed, modify button is pressed in the DBNavigator, the grid shows updated datafield. Great until now. When the Transaction is commited, in fact id seems to be rollback'ed.
See code:
procedure TF1.BCommitClick(Sender: TObject);
begin
if DM1.IBTransaction1.InTransaction then
  DM1.IBTransaction1.Commit;
DBGrid1.DataSource.DataSet.Close;
DM1.IBTransaction1.StartTransaction;
DBGrid1.DataSource.DataSet.Open;
end;

What's wrong ?

Thank you, folks.

Antonio.



0
Comment
Question by:antonio_fortuny
8 Comments
 

Expert Comment

by:rl912
ID: 8135419
Hello,

does the user have sufficient rights on the table ?

try CommitRetaining (see onlinehelp)
0
 

Author Comment

by:antonio_fortuny
ID: 8138376
Yes, I am logged in as SYSDBA.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 8237102
Try this code:

procedure TF1.BCommitClick(Sender: TObject);
begin
  if DBGrid1.DataSource.DataSet.Transaction.InTransaction then
  DBGrid1.DataSource.DataSet.Transaction.CommitRetaining;
end;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:esoftbg
ID: 8241500
Oh, excuse me,
I think you forgot to post Data before Commit Transaction:

procedure TF1.BCommitClick(Sender: TObject);
begin
  with DBGrid1.DataSource.DataSet do
  begin
    if (State in [dsInsert,dsEdit]) then
    begin
      if not Transaction.InTransaction then
        Transaction.StartTransaction;
      Post;
      Transaction.CommitRetaining;
    end;
  end;
end;
0
 

Author Comment

by:antonio_fortuny
ID: 8243469
Edit, data update and post were all done in a procedure before commit to DB. In fact, data was shown in the DBGrid as it was updated. Actually it wasn't.

I've replaced Delphi 5 IB components by original free IB compnents. They work OK ! Could it be possible that some  code inside Delphi 5 IB components was buggy ?
Thanks to all anyway.
Antonio.
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 200 total points
ID: 8248380
I do not believe it be possible that some code inside Delphi 5 IB components was buggy. I am using Delphi 6 IB components and they do work perfect !
 If you use more than one Transaction it is possible to Commit wrong one:
  1. Transaction is not DefaultTransaction for the DataBase;
  2. Transaction is not Transaction for the Posted DataSet;
I am very curious about the reasons for your troubles.
Emil.
0
 

Expert Comment

by:CleanupPing
ID: 9316876
antonio_fortuny:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 10090476
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: esoftbg

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question