例:
Case DBGrid1.DataSource.DataSet.Fields.FieldByName(字段名).DataType of
ftBCD: //对应MSSql数据库的decimal、money、numeric、smallmoney类型
end;
//其它的请看下面
TFieldType is a set of values that parallel the data types of fields in tables.
Unit
DB
type TFieldType = (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);
Value Sql Description
ftUnknown Unknown or undetermined
ftString char Character or string field
ftSmallint smallint 16-bit integer field
ftInteger int 32-bit integer field
ftWord tinyint 16-bit unsigned integer field
ftBoolean bit Boolean field
ftFloat float、real Floating-point numeric field
ftCurrency Money field
ftBCD decimal、money、 Binary-Coded Decimal field
numeric、smallmoney
ftDate Date field
ftTime Time field
ftDateTime datetime、smalldatetime Date and time field
ftBytes binary、timestamp Fixed number of bytes (binary storage)
ftVarBytes varbinary Variable number of bytes (binary storage)
ftAutoInc Auto-incrementing 32-bit integer counter field
ftBlob image Binary Large OBject field
ftMemo text Text memo field
ftGraphic Bitmap field
ftFmtMemo Formatted text memo field
ftParadoxOle Paradox OLE field
ftDBaseOle dBASE OLE field
ftTypedBinary Typed binary field
ftCursor Output cursor from an Oracle stored procedure (TParam only)
ftFixedChar Fixed character field
ftWideString nchar、nvarchar Wide string field
ftLargeInt bigint Large integer field
ftADT Abstract Data Type field
ftArray Array field
ftReference REF field
ftDataSet DataSet field
ftOraBlob BLOB fields in Oracle 8 tables
ftOraClob CLOB fields in Oracle 8 tables
ftVariant sql_variant Data of unknown or undetermined type
ftInterface References to interfaces (IUnknown)
ftIDispatch References to IDispatch interfaces
ftGuid uniqueidentifier globally unique identifier (GUID) values
查看类型的好方法
1)、在Delphi集成开发环境中建立一个新的应用程序项目。
2)、在主窗体中放入一个TADOTable组件。并且设定好它的ConnectionString属性以及从TableName属性中选择一个表。
3)、选择TADOTable组件,并且双击它,然后在弹出的Fields Editor窗口中单击鼠标右键选择Add All Fields菜单。这时会把所有字段都例举出来,然后任意选中一个你要查看类型的字段,在属性编辑器中就可以看到Ms Sql转换后的类型(图1)。我们看到的类型是TBytesField对应的就是ftBytes,以此类推。