帮我看下程序,老提示有错误(0分)

  • 主题发起人 主题发起人 2008hyc
  • 开始时间 开始时间
2

2008hyc

Unregistered / Unconfirmed
GUEST, unregistred user!
  程序老提示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.这是怎么回事啊,要怎么改啊,下面是程序帮我看看,谢谢!<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls, Buttons, DB, ADODB;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Label1: TLabel;<br>&nbsp; &nbsp; Label2: TLabel;<br>&nbsp; &nbsp; Edit1: TEdit;<br>&nbsp; &nbsp; Edit2: TEdit;<br>&nbsp; &nbsp; BitBtn1: TBitBtn;<br>&nbsp; &nbsp; BitBtn2: TBitBtn;<br>&nbsp; &nbsp; ADOQuery1: TADOQuery;<br>&nbsp; &nbsp; procedure BitBtn1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure BitBtn2Click(Sender: TObject);<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>uses main;<br><br>{$R *.dfm}<br><br>procedure TForm1.BitBtn1Click(Sender: TObject);<br><br>var<br>id,pwd:string;<br>begin<br>id:=edit1.text;<br>pwd:=edit2.text;<br>adoquery1.Close;<br>adoquery1.SQL.Clear;<br>adoquery1.SQL.Text:='select * from user where userid='''+id+''' and userpwd='''+pwd+'''';<br>adoquery1.Open;<br>if adoquery1.Recordset.RecordCount=0 then<br>&nbsp; begin<br>&nbsp; showmessage('用户或者密码输入错误,请重输!');<br>&nbsp; edit1.SetFocus;<br>&nbsp; end<br>&nbsp; else begin<br>&nbsp; &nbsp; &nbsp; &nbsp;hide;<br>&nbsp; &nbsp; &nbsp; &nbsp;mainform.ShowModal;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>end;<br><br>procedure TForm1.BitBtn2Click(Sender: TObject);<br>begin<br>application.Terminate;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>edit1.Clear;<br>edit2.Clear;<br>adoquery1.Connection:=main.mainform.ADOConnection1;<br>end;<br>end.
 
if adoquery1.Recordset.RecordCount=0 then &nbsp;这句好像有问题,改成<br>if adoquery1.RecordCount=0 then <br>但你报的错误应该不是这个引起的!看看你的main.mainform.ADOConnection1;<br>连接是否正常!
 
同意楼上的,你检查一下main.mainform.ADOConnection1是否正确,其Connected是否为True;<br>但是,if adoquery1.Recordset.RecordCount=0 then &nbsp;是正确的!adoquery1.Recordset是_RecordSet,可以这样表示的!
 
哦!呵呵,我也不太熟,多谢Living.Chan的指点!
 
mainform.ADOConnnection1的Connected是True,但是unit1里ADOQuery的active不知道为什么是False,不知道是哪里错了
 
这个是用户登录页面
 
你跟踪一下程序,看看是哪里报的错!
 
if adoquery1.isemty ....然后才涉及adoquery1.RecordCount
 

Similar threads

I
回复
0
查看
763
import
I
I
回复
0
查看
524
import
I
后退
顶部