You are not logged in.
Hi,
I have derived a simple component from TSynDBDataSet to override InternalInitFieldDefs procedure.
The component seem work fine except when I edit a record with 2 VarChar(2) field one with '13' and the next empty if the field are on a form with 2 Dbedit and I use Tab to cycle from Dbedit to another the value of the first field is copied to the next field.
procedure TMyMemDataSet.InternalInitFieldDefs;
var
lFields: TSQLDBColumnDefineDynArray;
DBType: TFieldType;
F: integer;
begin
if FieldDefs.Count > 0 then
exit;
if Connection = nil then
exit;
Connection.GetFields(PSGetTableName, lFields);
for F := Low(lFields) to High(lFields) do
begin
with lFields[F] do
begin
case ColumnType of
SynCommons.ftInt64:
begin
DBType := db.ftLargeint;
end;
SynCommons.ftDate:
begin
DBType := db.ftDateTime;
end;
SynCommons.ftUTF8:
if (ColumnLength = 0) then
begin
DBType := db.ftWideMemo;
end
else
begin
DBType := db.ftWideString;
end;
SynCommons.ftBlob:
begin
DBType := db.ftBlob;
end;
SynCommons.ftDouble, SynCommons.ftCurrency:
begin
DBType := db.ftFloat;
end
else
raise EDatabaseError.CreateFmt('GetFieldData ColumnType=%d', [ord(ColumnType)]);
end;
FieldDefs.Add(UTF8ToString(ColumnName), DBType, ColumnLength);
end;
end;
setLength(lFields, 0);
end;
p.s. I'm using Delphi XE 10.1
TIA
The mind is like a parachute, it only works if you open it.
Albert Einstein
Offline
Hi,
I have found a possible cause in SynDBMidasVCL the TSynDBDataSet use a Dataset TSynDBSQLDataSet associated with the TDataSetProvider. If I override the InternalInitFieldDefs procedure of TSynDBSQLDataSet seem to work correctly
procedure TSynDBSQLDataSet.InternalInitFieldDefs;
var F: integer;
DBType: TFieldType;
lFields: TSQLDBColumnDefineDynArray;
begin
FieldDefs.Clear;
if fconnection = nil then
exit;
fconnection.GetFields(PSGetTableName, lFields);
for F := Low(lFields) to High(lFields) do
begin
with lFields[F] do
begin
case ColumnType of
SynCommons.ftInt64:
begin
DBType := db.ftLargeint;
end;
SynCommons.ftDate:
begin
DBType := db.ftDateTime;
end;
SynCommons.ftUTF8:
begin
if ColumnLength = 0 then
begin
DBType := db.ftWideMemo;
end
else
begin
DBType := db.ftWideString;
end;
end;
SynCommons.ftBlob:
begin
DBType := db.ftBlob;
end;
SynCommons.ftDouble, SynCommons.ftCurrency:
begin
DBType := db.ftFloat;
end
else
raise EDatabaseError.CreateFmt('GetFieldData ColumnType=%d', [ord(ColumnType)]);
end;
FieldDefs.Add(UTF8ToString(ColumnName), DBType, ColumnLength);
end;
end;
setLength(lFields, 0);
end;
The mind is like a parachute, it only works if you open it.
Albert Einstein
Offline