⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 这是《Delphi程序设计基础》由李文池写的书的示例代码
💻 PAS
字号:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DBTables, DB, ADODB;

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    btnUpdate: TButton;
    edtNo: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    edtLastname: TEdit;
    ADOQuery1: TADOQuery;
    ADOTable1: TADOTable;
    ADOConnection1: TADOConnection;
    procedure btnUpdateClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnUpdateClick(Sender: TObject);
var s:String;
begin
  //更新指定员工编号的LastName
  with ADOQuery1 do
  begin
    if Active then
       Close;   //关闭数据集
    SQL.Clear ;
    s := 'update employee set LastName = ''' + edtLastname.Text + '''' +
              ' where EmpNo = ' + edtNo.Text ;
    SQL.Add(s);
    showmessage(s);
    ExecSQL;    //执行update语句
  end;

  //更新显示
  With ADOTable1 do
  begin
    Active := False;
    Open;
    Locate('EmpNo', edtNo.Text, []);
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -