Icon Frequently Asked Questions

I've got my data in another format and I want to convert it into DBISAM format. How do I do this ?

A data conversion can be accomplished by simply copying records from one TDataSet descendant component to the other by looping through the TFields and using the Assign method to assign the contents of a TField in one TDataset descendant component to the other.

Information Do not attempt to copy entire records at a time as a method of transferring data from one format to another. DBISAM may use an entirely different record layout than the one being used as the source of the data. Corruption and a general failure to work correctly may result.

{ The following is an example of looping through the
TFields and copying data from one TDataset descendant
to another }

SourceDataSet:=TMyDataSet.Create(Nil);
with SourceDataSet do
   begin
   DatabaseName:='SQLServer';
   TableName:='CUSTOMER';
   Active:=True;
   end;
DestDataSet:=TDBISAMTable.Create(Nil);
with DestDataSet do
   begin
   DatabaseName:='c:\testdb';
   TableName:='customer';
   Active:=True;
   end;
SourceDataSet.First;
while not SourceDataSet.EOF do
   begin
   DestDataSet.Insert;
   for I:=0 to SourceDataSet.FieldCount-1 do
      DestDataSet.FieldByName(
        SourceDataSet.Fields[I].FieldName).
          Assign(SourceDataSet.Fields[I]);
   DestDataSet.Post;
   SourceDataSet.Next;
   end;
SourceDataSet.Close;
DestDataSet.Close;

{ This example assumes that the source and
destination dataset field names will be the
same and it does not deal with copying the
structure or indexes, it simply copies the data }
Image