Update and Maintain dbExpress's Unidirectional, Read-Only Datasets
By Bob Swart, Delphi Pro

The good old Borland Database Engine (or any other Delphi data access library before dbExpress) provided datasets that had a bi-directional cursor, and they were directly connected to the database table. Even with a TQuery, you could use the RequestLive property to try and update the resulting dataset. Now with dbExpress, this is no longer the case. The datasets (TSQLDataSet, TSQLTable, TSQLQuery, or TSQLStoredProc) are not only unidirectional (they support moving one step ahead or all the way back to the beginning, but no other operations), they also are read-only. So we have no direct way to post a new or changed record to a TSQLDataSet.





After I've made changes to the datasets in a dbExpress application, when I exit and restart the application the datasets revert to their old values. How do I post a new or changed record to a dbExpress dataset when dbExpress provides only unidirectional, read-only datasets?



Using the ClientDataSet, which can utilize the DataSetProvider, you can connect back to the original dbExpress database. Then, using the ApplyUpdates method, you can drop a TButton on the Form and set its Caption property to Apply Updates. Another solution is to make it an automatic (apply) update. Apart from using a TSQLDataSet that uses a TDataSetProvider to put the records in a TClientDataSet component, we could also have used a TSQLClientDataSet component that in effect contains the three aforementioned components in one. And once you've selected the solution, make the solution code uniform and reusable.

  
Next: Read-Only, Unidirectional Datasets


Introduction SQLClientDataSet: The Three-in-One Solution
Read-Only, Unidirectional Datasets


Return to Get Help with Delphi Page

Return to Main Get Help Page
 


Find Out More
• Get the source code for this Solution!

• The DevX Database Development Zone

• Previous 10-Minute Solution: Migrate Your BDE Applications to Linux with dbExpress

• Dr. Bob's Delphi Clinic


TALK BACK
Do you expect dbExpress to replace the Borland Database Engine, especially since Kylix supports only dbExpress? Let us know in the Database Development discussion groups!
 





Sponsored Links