I've got my data in another format besides Paradox or dBase and I want to convert it into DBISAM format. How do I do this ?The best option if you can access the table via the BDE (or through the BDE and then an ODBC driver) is to use the BDE Database Transfer Utility to move the data from the original format into DBISAM format. When using the Delphi 3.0x (and above) or C++Builder 3.0x (and above) interface support for DBISAM you can have multiple TDataSet descendant components accessing different data formats at the same time. 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.
Note
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 (Delphi 3.0x and above only) }
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 }
| |
|
| |
|