Delphi开发工具中如何访问数据库结构

发表于:2007-7-24 09:59  作者:于海生 姚微   来源:天极网

字体: | 上一篇 | 下一篇 |我要投稿 | 推荐标签:

TFieldType定义如下:

以下是引用片段:
  TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord, ftBoolean,
  ftFloat,ftCurrency, ftBCD, ftDate, ftTime, ftDateTime, ftBytes, ftVarBytes,
  ftAutoInc,ftBlob, ftMemo, ftGraphic, ftFmtMemo, ftParadoxOle, ftDBaseOle,
  ftTypedBinary,ftCursor);


  TIndexOptions定义如下:

以下是引用片段:
TIndexOptions = set of (ixPrimary, ixUnique, ixDescending, ixExpression, ixCaseInsensitive);


  它们的具体意义可以参见Delphi帮助。

   5 应用实例

  使用下面的程序片段即可获得指定数据库中指定表的域定义和索引定义。ListBox1、ListBox2 和 ListBox3 为Form1中定义的三个列表框,用于显示结果。

以下是引用片段:

Var  Alias,TableName:String;
Table1:TTable;
Begin
Alias:='fjs';  TableName:='d*';    //初始化
Session.GetTableNames(Alias, {别名}
                      TableName, {过滤器}
                      True, {是否显示文件扩展名(对DBF) }
                      False, {是否显示系统表}
                      ListBox1.Items);
If ListBox1.Items.Count=0 then
  Begin
    MessageDlg('数据库'+Alias+'中没有数据表'+TableName, mtError, [mbOK], 0 );
  Exit;
End;
Table1:=TTable.Create(nil);
Table1.DatabaseName :=Alias;
Table1.TableName := ListBox1.Items.Strings[0];
{取得表中字段名及索引名}
Table1.Open;
if Table1.Active then
begin
Table1.GetFieldNames(ListBox2.Items);
   Table1.GetIndexNames(ListBox3.Items);
end;
//… 此时结果在ListBox2和ListBox3中
//
Table1.Destroy;
end;


  6 小结

  通过上面讨论和实例证明,利用Delphi语言开发数据库软件管理系统,关键技术都已得到解决。

  参考文献

  [1] (李维 编著).《DELPHI 7高效数据库程序设计》机械工业出版社2003.1

  [2] 郭旭等 著.《Delphi6应用开发指南》清华大学出版社2004.6

  [3] 大富翁http://www.delphibbs.com/

 


【福利】填问卷 送2019精选测试大礼包+接口测试实战课程!
22/2<12

评 论

论坛新帖

顶部 底部


建议使用IE 6.0以上浏览器,800×600以上分辨率,法律顾问:上海瀛东律师事务所 张楠律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2020, 沪ICP备05003035号
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪公网安备 31010102002173号

51Testing官方微信

51Testing官方微博

扫一扫 测试知识全知道