内容为null时通过synDBDataSet读出字段类型为wideMemo


//MSSQL表中的字段是nvarchar格式,内容为null时通过synDBDataSet读出字段类型为wideMemo,将synDBVCL.pas单元procedure TSynBinaryDataSet.InternalInitFieldDefs按下面的方法修改就可以。

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
SynTable.ftInt64: DBType := ftLargeint;
SynTable.ftDate: DBType := ftDateTime;
SynTable.ftUTF8:
if ColumnDataSize=0 then
DBType := ftWideString else //ftDefaultMemo else
DBType := ftWideString; // means UnicodeString for Delphi 2009+
SynTable.ftBlob: DBType := ftBlob;
SynTable.ftDouble, SynTable.ftCurrency: DBType := ftFloat;
else raise EDatabaseError.CreateFmt(
'GetFieldData ColumnType=%s',[TSQLDBFieldTypeToString(ColumnType)]);
end;
FieldDefs.Add(UTF8ToString(ColumnName),DBType,ColumnDataSize);
end;
end;

 

posted @ 2020-05-14 15:43  Thenext  阅读(295)  评论(0编辑  收藏  举报