注册 登录
编程论坛 Delphi论坛

帮我看下程序,老提示有错误

心~梦 发布于 2008-03-22 11:16, 928 次点击
  程序老提示project project2.exe raised exception class EAccessViolation with message'Access violation at address 0048cbfe in module'project2.exe'.read of address 000002f8'. process stoped.use step or run to continue.这是怎么回事啊,要怎么改啊,下面是程序帮我看看,谢谢!
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ADOQuery1: TADOQuery;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses main;

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);

var
id,pwd:string;
begin
id:=edit1.text;
pwd:=edit2.text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select * from user where userid='''+id+''' and userpwd='''+pwd+'''';
adoquery1.Open;
if adoquery1.Recordset.RecordCount=0 then
  begin
  showmessage('用户或者密码输入错误,请重输!');
  edit1.SetFocus;
  end
  else begin
       hide;
       mainform.ShowModal;
       end;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
adoquery1.Connection:=main.mainform.ADOConnection1;
end;
end.
1 回复
#2
shuihan20e2008-03-24 12:24
估计是这句出错吧
mainform.ShowModal;
在显示该窗体前你有没有创建它?
可以看下你的工程文件
你可以改成自动创建的,也可以这样写
假设类名是
TFrmMain
TFrmMain.Create(nil).ShowModal;
1