发信人: redfox (Z掉了几乎所有的版...), 信区: BorlandDev
标  题: Delphi编程 -- 10.5 表名输出到一个选择框
发信站: 哈工大紫丁香 (2000年09月01日16:50:57 星期五), 站内信件

怎样把可以使用的表名输出到一个选择框?  
How to put all the table names available in a select box?
问:
I have found out this :-
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
   Session.GetTableNames(ComboBox1.Text,'', False,False,ComboBox2.
Items);
   Table1.DatabaseName := ComboBox1.Text;
end;
However, GetTableNames also return a query. so, when the user click on 
the query, the program crashed...
答:
You seem a little confused between Databases and Tables.
In Delphi, a database refers to a collection of tables, and typically
refers to a directory.
First get a list of databases

Session.GetAliasNames(AliasComboBox.Items);

Now get the tablenames using the selected Alias

 Session.GetTableNames(AliasComboBox.Text,'*.db',
False,False,TableComboBox.Items);

Then set the DataBaseName and TableName properties
   Table1.DatabaseName := AliasComboBox.Text;
   Table1.TableName := TableComboBox.Text;


 

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.227.107]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.317毫秒