?
Solved

Delphi (5) and Interbase: TIBDataSet updating

Posted on 2003-03-09
9
Medium Priority
?
455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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