Discussion Locked

programming problem

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

This is what I'm doing - I am working on creating a database. So far I was successful on editing, inserting, deleting, and navigating through records. But I have two problems: 1) if I make a change to a record or multiple records I want any and all unsaved changes to be discarded when the program closes and 2) I want to save the entire database instead of just one record.

Now, I have tried looking through the developers guide and tried looking through the book, C++ Builder 4 Unleashed, forthe previous version not to mention a few websites. I can't find nothing on creating the necessary event handlers to complete the tasks.

Could anyone offer some advice or sample code I can use to complete the tasks?

I am using Boreland C++ Builder 5 Professional edition.

Neil

9 replies

by chrandrob

What type of database? What kind of connection are you creating to it? Is it contained within the application or external?
Etc.

by tink

Typically you want to issue a COMMIT to save all changes or a ROLLBACK to undo all changes. I'm not familiar enough with C++ Builder to offer you any sample code.

I hope the COMMIT/ROLLBACK options will point you in the right direction.

GL,
TINK

by bill

First, knowing exactly what database engine you're interacting with (if any), would allow a more specific answer.

In general, when working with a database, you are only dealing with a small subset of records, not the entire database. Your program extracts the 'view' you've requested, you then add/edit/delete items to that 'view', and then update the master (the actual database) when you're finished, or you discard the 'session', that is all the changes you made to the 'view' you were working with.

The entire database never needs to be 'saved' again, as each change updates those records that have changed.

A database does not (at least those I'm familiar with) like say a Word processing document or a spreadsheet, in that those applications often load entirely into the local PC's memory space, and need to be 'saved' as a version, where the only portion of the database that's in the local PC's memory space (and only then on fat-client apps) is that 'view' I mentioned.

I hope this helps... if you have more specifics.. I can get more specific as well.

by mtadeu

If you're using the ADO, you should take a good look at the beginTrans, commit and rollback methods! other way, but less eficient, is to have a paralel data structure to hold data and insert it in the database whenever you want

Good luck,
MiguelTadeu

This discussion is closed to new replies.