You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Delphi 11创建含ADT字段的BDE TTable时提示“Capability not supported”错误

BDE是否支持ADT字段?

结论

BDE 不支持直接创建或使用ADT(抽象数据类型)字段,这正是你遇到“capability not supported”错误的原因。

原因说明

BDE(Borland Database Engine)是一款老旧的数据库访问组件,设计初衷仅支持传统关系型数据库的基础字段类型(如字符串、数值、日期等),对ADT这类复杂的结构化字段没有原生支持。即便你在FieldDefs中定义了ftADT类型,BDE的底层驱动也无法处理该类型字段的创建与存储逻辑。

替代方案

若需要存储结构化复合数据,可参考以下几种方式:

  • 将ADT拆解为多个独立的普通字段(例如把Address的City、Road、Number分别设为单独的字符串字段)
  • 使用字符串字段存储JSON/XML格式的结构化数据,读取时再进行解析
  • 迁移至FireDAC、ADO等更现代的数据库访问组件,它们支持更丰富的字段类型与复杂数据结构

可复现代码

窗体声明

object Form14: TForm14
  Left = 0
  Top = 0
  Caption = 'Form14'
  ClientHeight = 442
  ClientWidth = 628
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = 'Segoe UI'
  Font.Style = []
  OnCreate = FormCreate
  TextHeight = 15
  object DBGrid1: TDBGrid
    Left = 0
    Top = 128
    Width = 628
    Height = 314
    Align = alBottom
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -12
    TitleFont.Name = 'Segoe UI'
    TitleFont.Style = []
  end
  object DataSource1: TDataSource
    DataSet = Table1
    Left = 120
    Top = 168
  end
  object Table1: TTable
    FieldDefs = <
      item
        Name = 'Address'
        ChildDefs = <
          item
            Name = 'City'
            DataType = ftString
            Size = 20
          end
          item
            Name = 'Road'
            DataType = ftString
            Size = 20
          end
          item
            Name = 'Number'
            DataType = ftString
            Size = 5
          end>
        DataType = ftADT
        Size = 3
      end>
    StoreDefs = True
    Left = 128
    Top = 72
  end
end

单元代码

unit Unit141;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Bde.DBTables, Vcl.Grids, Vcl.DBGrids;

type
  TForm14 = class(TForm)
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Table1: TTable;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form14: TForm14;

implementation

{$R *.dfm}

procedure TForm14.FormCreate(Sender: TObject);
begin
    if not Table1.Exists
    then Table1.CreateTable;
    Table1.Open;
end;

end.

PS. 已尝试将ObjectView设置为TRUE和FALSE


内容的提问来源于stack exchange,提问作者user3140961

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 07:31:11