📄 mainfrm.pas
字号:
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, DB, DBTables, StdCtrls;
type
TMainForm = class(TForm)
dbMain: TDatabase;
lbTables: TListBox;
dsMain: TDataSource;
dbgMain: TDBGrid;
qryMain: TQuery;
lblTables: TLabel;
procedure FormCreate(Sender: TObject);
procedure lbTablesClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
procedure TMainForm.FormCreate(Sender: TObject);
begin
{ First, get a list of table names for the user to select }
Session.GetTableNames(dbMain.DatabaseName, '', False, False, lbTables.Items);
end;
procedure TMainForm.lbTablesClick(Sender: TObject);
{ Define a constant string from which the SQL string will be built }
const
SQLString = 'SELECT * FROM %s';
begin
with qryMain do
begin
Close; // Make sure the query is closed.
SQL.Clear; // Clear any previous SQL statement.
{ Now add the new SQL statement constructed with the format
function }
SQL.Add(Format(SQLString, [lbTables.Items[lbTables.ItemIndex]]));
Open; { Now open Query1 with the new statement }
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -