📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, DBClient, SimpleDS, SqlExpr,
DBXpress;
type
TForm1 = class(TForm)
SQLConnection1: TSQLConnection;
SimpleDataSet1: TSimpleDataSet;
datasource1: TDataSource;
btnConnect: TButton;
btnCommit: TButton;
btnQuery: TButton;
DBGrid1: TDBGrid;
lbl1: TLabel;
procedure btnConnectClick(Sender: TObject);
procedure btnQueryClick(Sender: TObject);
procedure btnCommitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnConnectClick(Sender: TObject);
begin
if SQLConnection1.Connected=true then
SQLConnection1.Connected:=false;
SQLConnection1.Params.Clear;
SQLConnection1.Params.Values['user_name']:='sysdba';
SQLConnection1.Params.values['password']:='masterkey';
sqlConnection1.Params.Values['SQLDialect']:='3';
SQLConnection1.Params.Values['database']:=extractfilepath(paramstr(0))+'data\demo.fdb';
SQLConnection1.Connected:=true;
showmessage('连接成功');
end;
procedure TForm1.btnQueryClick(Sender: TObject);
begin
if not sqlConnection1.Connected then
begin
showmessage('请先连接');
exit;
end;
SimpleDataSet1.DataSet.CommandText:='select * from STUDENT';
simpleDataSet1.Open;
end;
procedure TForm1.btnCommitClick(Sender: TObject);
begin
if simpleDataSet1.ApplyUpdates(-1)>0 then
showmessage('提交数据不成功!')
else
showmessage('提交数据成功!');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -