当SQL表中的nvarchar字段类型内容为null时synDBDataSet使用ftwideMemo类型造成不能修改的问题,按下面红字修改synDBVCL.pas就可以:
synDBVCL.pas
procedure TSynBinaryDataSet.InternalInitFieldDefs;
var F: integer;
DBType: TFieldType;
begin
FieldDefs.Clear;
if fDataAccess=nil then
exit;
for F := 0 to fDataAccess.ColumnCount-1 do
with fDataAccess.Columns[F] do begin
case ColumnType of
SynCommons.ftInt64: DBType := ftLargeint;
SynCommons.ftDate: DBType := ftDateTime;
SynCommons.ftUTF8:
DBType := ftWideString; // means UnicodeString for Delphi 2009+
SynCommons.ftBlob: DBType := ftBlob;
SynCommons.ftDouble, SynCommons.ftCurrency: DBType := ftFloat;
else raise EDatabaseError.CreateFmt(
'GetFieldData ColumnType=%s',[TSQLDBFieldTypeToString(ColumnType)]);
end;
FieldDefs.Add(UTF8ToString(ColumnName),DBType,ColumnDataSize);
end;
end;