不好意思,第一次提问,没讲清楚,书上的一个例子,TSESSION的,用的是TSESSION的
GetAliasNames获得BDE别名,GetTableNames取得表名,代码如下.想请教关于BDE会话期的解释.
procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.cursor:=crHourglass;
with Listbox1 do
begin
Items.Clear;
Session.GetAliasNames(Items);
end;
Screen.Cursor := crDefault;
if ListBox1.Items.Count < 1 then
MessageDlg( 'There are no database aliases currently defined. You ' +
'need at least one alias to use this demonstration.',
mtError, [mbOK], 0 );
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
strValue: string;
bIsLocal: Boolean;
slParams: TStringList;
iCounter: Integer;
begin
with ListBox1 do
strValue := Items.Strings[ItemIndex];
ListBox2.Items.Clear;
Session.GetTableNames(strValue,
' ',
CheckBox1.Checked,
CheckBox2.Checked,
ListBox2.Items);
Screen.Cursor:=crDefault;
if LIstBox2.Items.Count < 1 then
MessageDlg('你选的数据库中没有表,请选择其他的数据库别名',mtError,[mbOK],0);
ListBox3.Items.Clear;
end;
procedure TForm1.ListBox2Click(Sender: TObject);
begin
Screen.Cursor:=crHourglass;
try
if Table1.Active then
Table1.Close;
with LIstBox1 do
Table1.DatabaseName:=Items.Strings[ItemIndex];
Table1.Open;
if Table1.Active then
Table1.GetFieldNames(ListBox3.Items);
finally
Screen.Cursor:=crDefault;
end;
end;
end.