更改密码”程序的错误,请高手指导指正。 ( 积分: 0 )

  • 主题发起人 主题发起人 不变的关怀
  • 开始时间 开始时间

不变的关怀

Unregistered / Unconfirmed
GUEST, unregistred user!
程序作了一定的修改,不过目前是这样的错误提示:[错误] Project1.dpr(11): Constant object cannot be passed as var parameter

下面是程序代码,请高手指导。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, DBTables;

type
TchangePasswordForm = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Query1: TQuery;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
procedure initiate;
public
{ Public declarations }

end;

var
changePasswordForm: TchangePasswordForm;
NAME,PASSWD:string;
implementation

{$R *.dfm}
//退出该模块
procedure TchangePasswordForm.BitBtn2Click(Sender: TObject);
begin
query1.Close;
close;
end;

procedure TchangePasswordForm.BitBtn1Click(Sender: TObject);
begin
query1.RequestLive:=true;
if edit2.Text=edit3.Text then
begin
query1.SQL.Clear;
query1.SQL.add('select * from POSTBANK.POST_CZY where USERNAME=:NAME');
edit1.Text:=query1.ParamByName('NAME').AsString;
query1.Open;
if query1.RecordCount=1 then
begin
//如果两次密码一致就修改
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('update POSTBANK.POST_CZY set USERPW=:PASSWD where USERNAME=:NAME');
edit1.Text:=query1.ParamByName('NAME').AsString;
edit2.Text:=query1.ParamByName('PASSWD').AsString;
query1.ExecSQL;
initiate;
end
else
begin
Application.MessageBox('没有该用户,请检查!','提示信息',mb_OK);
end;
end
else
begin
Application.MessageBox('您两次输入的密码不一致,请检查!','提示信息',mb_OK);
initiate;
end;
end;

procedure TchangePasswordForm.initiate;
begin
if NAME<>'admin' then
begin
edit1.Text:=NAME;
edit1.Enabled:=false;
edit1.TabStop:=false;
edit2.setfocus;
end
else
begin
edit1.Text:='';
edit1.setfocus;
end;
edit2.Text:='';
edit3.Text:='';
end;

procedure TChangePasswordForm.FormActivate(Sender: TObject);
begin
initiate;
end;
end.
 
程序作了一定的修改,不过目前是这样的错误提示:[错误] Project1.dpr(11): Constant object cannot be passed as var parameter

下面是程序代码,请高手指导。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, DBTables;

type
TchangePasswordForm = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Query1: TQuery;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
procedure initiate;
public
{ Public declarations }

end;

var
changePasswordForm: TchangePasswordForm;
NAME,PASSWD:string;
implementation

{$R *.dfm}
//退出该模块
procedure TchangePasswordForm.BitBtn2Click(Sender: TObject);
begin
query1.Close;
close;
end;

procedure TchangePasswordForm.BitBtn1Click(Sender: TObject);
begin
query1.RequestLive:=true;
if edit2.Text=edit3.Text then
begin
query1.SQL.Clear;
query1.SQL.add('select * from POSTBANK.POST_CZY where USERNAME=:NAME');
edit1.Text:=query1.ParamByName('NAME').AsString;
query1.Open;
if query1.RecordCount=1 then
begin
//如果两次密码一致就修改
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('update POSTBANK.POST_CZY set USERPW=:PASSWD where USERNAME=:NAME');
edit1.Text:=query1.ParamByName('NAME').AsString;
edit2.Text:=query1.ParamByName('PASSWD').AsString;
query1.ExecSQL;
initiate;
end
else
begin
Application.MessageBox('没有该用户,请检查!','提示信息',mb_OK);
end;
end
else
begin
Application.MessageBox('您两次输入的密码不一致,请检查!','提示信息',mb_OK);
initiate;
end;
end;

procedure TchangePasswordForm.initiate;
begin
if NAME<>'admin' then
begin
edit1.Text:=NAME;
edit1.Enabled:=false;
edit1.TabStop:=false;
edit2.setfocus;
end
else
begin
edit1.Text:='';
edit1.setfocus;
end;
edit2.Text:='';
edit3.Text:='';
end;

procedure TChangePasswordForm.FormActivate(Sender: TObject);
begin
initiate;
end;
end.
 
后退
顶部