Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 28957, Import any dataset table (like Dbf, Paradox tables) into MySQL

by Julio Pi√£o Email: mauricio_box@yahoo.com


Import any dataset fields (like Dbf, Paradox tables) into MySQL

You need to install Cindy components in order to use TcyDBXImportDataset component.

https://sourceforge.net/projects/tcycomponents/
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 7.0  to 15.0 0 downloads
Copyright: Open Source or other


Size: 0 bytes
Updated on Mon, 30 Jul 2012 09:28:21 GMT
Originally uploaded on Mon, 30 Jul 2012 09:28:21 GMT
Description
uses BDE;

cyDbxImportDataset1.Dataset := ParadoxTable;
cyDbxImportDataset1.TableName := MySQLTableName;
cyDbxImportDataset1.PrimaryKey := 'Id' + MySQLTableName;

// Correct BDE table fields size (optional) :
try
TabProp := TFrmBDEDataset(FrmPrin.ActiveMDIChild).TbFile;
pFlds := AllocMem((TabProp.FieldCount + 1) * sizeof(FLDDesc));
FillChar(pFlds^, (TabProp.FieldCount + 1) * sizeof(FLDDesc), 0);
Check(DbiGetFieldDescs(TabProp.handle, pFlds));

for f := 0 to TabProp.FieldCount-1 do
begin
FieldIndex := cyDbxImportDataset1.Fields.FindFieldIndex(TabProp.Fields[f].FieldName);

if f <> 0 then
Inc(pFlds, 1);

{ Case pFlds^.iFldType Of
1: StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'String';
2: StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'Date';
3: StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'Memo';
4: StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'Bool';
5: StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'Integer';
6: StringGridProps.Cells[2, StringGridProps.RowCount-1] := '???';
7: StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'Float';
Else
StringGridProps.Cells[2, StringGridProps.RowCount-1] := 'Ché pas';
End; }

if pFlds^.iFldType in [1, 5, 7] then
cyDbxImportDataset1.Fields[FieldIndex].FieldType.Size := pFlds^.iUnits1;

if pFlds^.iFldType = 7 then // Floats
begin
cyDbxImportDataset1.Fields[FieldIndex].FieldType.Precision := pFlds^.iUnits2;

// Convert Float fields without decimals to an Integer:
if cyDbxImportDataset1.Fields[FieldIndex].FieldType.Precision = 0 then
cyDbxImportDataset1.Fields[FieldIndex].FieldType.DataType := ftInteger;
end;
end;
finally
pFlds := Nil;
FreeMem(pFlds);
end;

// Create table :
cyDbxImportDataset1.CreateTable;

// Export records :
if CBExportRecords.Checked then
begin
Screen.Cursor := crHourGlass;
cyDbxImportDataset1.Dataset.DisableControls;
cyDbxImportDataset1.ImportRecords;
cyDbxImportDataset1.Dataset.EnableControls;
Screen.Cursor := crDefault;
end;

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Server Response from: ETNACDC03