[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Failure to edit or delete records using IBX

Posted on 2006-06-04
5
Medium Priority
?
561 Views
Last Modified: 2013-12-09
This should be an easy question to answer.  I have a ready-made interbase (v6) database I want to manipulate using Delphi (v6)  and IBX components.  I can insert records without a problem, but cannot edit or delete records.
I have a TIBDatabase, IBTransaction, IBDataset, and a DataSource hooked up together with the Dataset SelectSQL = ‘Select * from mytable’ and all the other SQL strings autogenerated.
I can insert using:
   MyTransaction.StartTransaction;
   MyDataset.Open;
   MyDataset.Insert;
.
(fill fields in here)
.
   MyDataset.Post;
   MyDataset.Close;
   MyTransaction.Commit;

No problem.  But, when I try to edit by:

   MyTransaction.StartTransaction;
   MyDataset.Open;
   MyDataset.Edit;
.
(Modify fields in here)
.
   MyDataset.Post;
   MyDataset.Close;
   MyTransaction.Commit;
 
Nothing appears to happen.  Similarly with delete.  
I’ve tried using cachedupdates and even writing the ModifySQL statement to SelectSQL and using MyDataset.ExecSQL without success.  Can somebody tell me what I’m doing wrong?
0
Comment
Question by:TonyNJones100
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:kacor
ID: 16839704
Hi Tony,

really happens nothing? In InterBase every action happens within a transaction. If the transaction finishes sometimes the session is ended. To see the database eg. the result of your activity you have to begin a new session.

Please check whether the modification or deletion you made happened in reality!

kacor
0
 

Author Comment

by:TonyNJones100
ID: 16841881
Yes.  Nothing happens.  I can step through each of the statements above in Delphi without it or Interbase complaining.  When I inspect the database (I use IB Expert) the records are as before.
Can I presume that you have no objection to the coding above?  Would you expect it to work?
Tony
0
 
LVL 10

Expert Comment

by:kacor
ID: 16846446
Tony,

may be you made something wrong setting the IBDataSet (IBX-Component) in Delphi. (I use D7).

Now I tell you the procedure step by step:

1. Select MyIBDataSet in the Object Inspector.
2. In Properties click on Database and select MyIBDatabase
3. Click on Default Transaction and select MyTransaction
4. You have to set the SelectSQL property
4.1 Click on the 3-dot-Button in the right panel and opens the Command Text Editor
4.2 Select mytable in the tables list, then double click on the *, then double click on mytable and appears the SelectSQL command: select * from mytable (or you can write manuell)
5. Open the Dataset editor: rightclick on MyIBDataSet and select Dataset editor.
6. Select MyTable then click on Select Primary Keys button, then click on Generate SQL button by this way the Insert, Modify, Delete and Refresh commands are autogenerated (which differ from the statement wrote you by hand I mean). Of course if you need a more complex SQL statement you have to write it.
7. Set Active to True

And everything will be OK I hope

wbr kacor

0
 
LVL 10

Accepted Solution

by:
kacor earned 500 total points
ID: 16846558
Place a DBGrid and a DBNavigator (with active hints) on your form, connect to DataSource and you can directly test the above said
0
 

Author Comment

by:TonyNJones100
ID: 16849996
Thank you; problem solved.  The problem was in the autogenerated SQLs.  I had not fully understood the process of generating them and had included ALL the fields as primary key instead of just the allocated primary key.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 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