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精选测试大礼包+接口测试实战课程!