从delphi 7迁移到delphi XE4时出现TSQLDataset错误

时间:2013-09-24 07:15:03

标签: delphi delphi-7 firebird delphi-xe4 dbexpress

我在Delphi 7应用程序中跟随TSQLDataSet。它从表MyTable中获取2个字段(ID和Name)。

object SQLDataSet: TSQLDataSet
    GetMetadata = False
    CommandText = 'select * from MyTable'
    MaxBlobSize = -1
    Params = <>
    SQLConnection = mySQLConnection

    object SQLDataSetID: TIntegerField
      FieldName = 'ID'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object SQLDataSetNAME: TStringField
      FieldName = 'NAME'
      Required = True
      Size = 50
    end
end

当我迁移到Delphi XE4时,我收到以下错误:

class EDatabaseError with message 'SQLDataSet: Type mismatch for field 'NAME', expecting: String actual:WideString'

这个问题的可能原因是什么?我应该如何摆脱它?

注意:我使用的是firebird 2.5.2

1 个答案:

答案 0 :(得分:0)

TStringField更改为TWideTStringfield

object SQLDataSet: TSQLDataSet
    GetMetadata = False
    CommandText = 'select * from MyTable'
    MaxBlobSize = -1
    Params = <>
    SQLConnection = mySQLConnection

    object SQLDataSetID: TIntegerField
      FieldName = 'ID'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object SQLDataSetNAME: **TWideStringField**
      FieldName = 'NAME'
      Required = True
      Size = 50
    end
end