Mega Code Archive

 
Categories / Delphi / ADO Database
 

Create Your Own Custom Dataset (part Due)

Title: Create Your Own Custom Dataset (part Due) Question: How to create direct access dataset Answer: Creating Custom Datasets (Part DUE) Want to read "Create You Own Custom Dataset!" (Part 1) In this tutorial we will see how to create a working Table with Dynamic Field Defs, just like a normal table. Next tutorial we will learn no make a DAC:DBF (DBase III) DataSet. And we will lean to use Indexing, Filtering, Etc. Standard Table Layout Structure Size in Bytes Header 6 Field Defs ??? Actual Data ??? File Header Field Size in Bytes Table ID 2 Version 1 Sub Version 1 FieldDefs Count 2 FieldDefs Count contains the amount of FieldRecords to read Field Defs Record We will focus on the main data types, for example Strings, Integer, Float, Etc. Field Size in Bytes Name 20 DataType 2 Size 2 Required 2 How to process file InternalOpen This procedure will have to read the File Header, Store the FieldDef Count and Call InitFieldDefs InternalInitFieldDefs This procedure will have to read the FieldDefs Records and convert them his own format. Read Header from Position 0 to Header Size (in this case the header size is 6 bytes) Store FieldDefs Record-Count Read FieldDefs Record(s) Convert Record to actual FieldDefs Tutorial Download Now for the HANDS-ON part of the tutorial! The code was writen in Delphi 6 and working just fine. The archive contains not only the THGDataSet source but a Table Builder application source. Download NOW! (WinRAR 3.0 Required) Word to the wize Practice makes perfect, please write your own and read the source carefully, download both this part and the first part archives to get a better feel to the changes. I change my coding style alittle every tutorial, from easy to hard so read carefully. All sources are WELL commentated. ENJOY!