• FDQuery 怎么能插入NULL参数


    [FireDAC][Phys][MSSQL]-335. Parameter [fieldAA] data type is unknown. Hint: specify TFDParam.DataType or assign TFDParam value before Prepare/Execute call

    以前BDE可以。

    ADO

     qrypub->ParamByName("fieldAA")->DataType= ftDateTime;

    qrypub->ParamByName("fieldAA")->DataType= ftString;

    DataType就是字段类型,设置字段类型就可以插入NULL值了,不赋值执行insert或update语句自动填充为NULL值了。

    2016.9.23 record,

    fdquery有个属性,FormatOptions.DefaultParamDataType=ftUnknow,默认是ftUnknown,改为ftString或者ftVariant也许就好了,未测试。

    2017.5.11 测试用ftString是ok了。

    qrypub->FormatOptions->DefaultParamDataType = ftString;

           FDQuery1.FormatOptions.DefaultParamDataType := ftString;

    TFieldType : unsigned char { ftUnknown, ftString, ftSmallint, ftInteger, ftWord, ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime, ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic, ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftFixedChar, ftWideString, ftLargeint, ftADT, ftArray, ftReference, ftDataSet, ftOraBlob, ftOraClob, ftVariant, ftInterface, ftIDispatch, ftGuid, ftTimeStamp, ftFMTBcd, ftFixedWideChar, ftWideMemo, ftOraTimeStamp, ftOraInterval, ftLongWord, ftShortint, ftByte, ftExtended, ftConnection, ftParams, ftStream, ftTimeStampOffset, ftObject, ftSingle };

    TADTField
    TAggregateField
    TArrayField
    TAutoIncField
    TBCDField
    TBinaryField
    TBlobField
    TBooleanField
    TByteField
    TBytesField
    TCurrencyField
    TDataSetField
    TDateField
    TDateTimeField
    TExtendedField
    TFloatField
    TFMTBCDField
    TGraphicField
    TGuidField
    TIDispatchField
    TIntegerField
    TInterfaceField
    TLargeintField
    TLongWordField
    TMemoField
    TNumericField
    TObjectField
    TReferenceField
    TShortintField
    TSingleField
    TSmallintField
    TSQLTimeStampField
    TSQLTimeStampOffsetField
    TStringField
    TTimeField
    TUnsignedAutoIncField
    TVarBytesField
    TVariantField
    TWideMemoField
    TWideStringField
    TWordField

    Param [PName] type changed from [ftString] to [ftFixedChar]. Query must be reprepared. Possible reason: an assignment to a TFDParam.AsXXX property implicitly changed the parameter data type. Hint: use the TFDParam.Value or appropriate TFDParam.AsXXX property.

    ftFixedChar 对应的数据库字段类型是char

    ftString 对应的数据库字段类型是varchar

    所以修改数据库类型即可。

  • 相关阅读:
    《构建之法》阅读笔记02
    《构建之法》阅读笔记01
    学习进度
    “校园知网”端午假期冲刺计划书
    学习进度
    计算最长英语单词链
    第一周冲刺_周日总结
    构建之法阅读笔记03
    第一周冲刺_周六总结
    软件工程概论第十四周学习进度
  • 原文地址:https://www.cnblogs.com/cb168/p/5594996.html
Copyright © 2020-2023  润新知