Porting a Simple Custom Dataset

For Mastering Delphi 7 I wrote143 a custom dataset based on a record-to-stream architecture. So I thought that porting that custom dataset to Delphi 2009 would be a good test of the effort involved in such a process.

143 The original code actually dates back to my Delphi Developer Handbook, written for Delphi 3, and was modified for the Delphi 7 book. I have no room here to cover in detail what it takes to write a custom dataset, as that is far from an easy task. If you are interested in learning about the details of how to write a custom dataset you can refer to one of those two old books of mine.

Having done this porting (without going all the length to support Unicode strings in my dataset), I have to say it was simple. The custom dataset is divided in two source code units: the MdDsCustom unit, which defines an abstract high level TMdCustomDataSet class, and the MdDsStream unit, which defines the actual implementation class TMdDataSetStream.

I opened both units, did a Search/Replace of PChar to TRecordBuffer finding 19 occurrences in the first unit and 4 in the second, and accepted them all. Most of the references to PChar where in the signature of the virtual methods that have been modified, a couple were local temporary variables used to store the current buffer, obtained with the ActiveBuffer method of the TDataSet class that now returns a TRecordBuffer.

At this point the component would compile. In the main program I had to tweak the code for testing bookmarks, by declaring the local variable as:

That was it! In a matter of minutes the custom dataset was up and running, and I could even reopen an existing demo file, with some data. The dataset source code files and the demo program are available in the StreamDsDemo folder. Here is the sample output:

T0 Dataset One Demo 1 ■=■ I B

Create New Table W Active m -i ►

w + -

P4 Bookmark test










[email protected]





[email protected]





¡[email protected]

1 Marco again




m cornar co can tu com



1 * y

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment