📄 main.pas
字号:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, DB, DBTables;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Table1: TTable;
Database1: TDatabase;
DataSource1: TDataSource;
Label1: TLabel;
DBGrid1: TDBGrid;
procedure FormShow(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
//将数据库中的所有普通数据表添加到ListBox1中
with Database1 do
begin
AliasName := 'ODBC_SQLServer';
DatabaseName := 'ODBC_SQLServer';
Open;
if Connected then
GetTableNames(ListBox1.Items, False)
else
begin
ShowMessage('不能打开ODBC_SQLServer数据源');
close;
end;
end;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
//显示选中的表的数据
with table1 do
begin
if Active then
Active := False;
TableName := ListBox1.Items[ListBox1.ItemIndex];
Active := True;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -