Cindy V5.06 released!
Для просмотра ссылки Войди или Зарегистрируйся
Need export BDE table or any dataset to mysql?
Use my new TcyDBXImportDataset component!
Sample code:
uses BDE;
cyDbxImportDataset1.Dataset := ParadoxTable;
cyDbxImportDataset1.TableName := MySQLTableName;
cyDbxImportDataset1.PrimaryKey := 'Id' + MySQLTableName;
// Correct fields size :
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;
Mauricio