首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

一段Delphi代码,编译通过,运行时有异常

2013-09-16 
【求助】一段Delphi代码,编译通过,运行时有错误分为老师、管理员和学生不同的登录权限,运行提示raised except

【求助】一段Delphi代码,编译通过,运行时有错误
分为老师、管理员和学生不同的登录权限,运行提示raised exception class EOleException with message '关键字'user'附近有语法错误。‘
但是检查了几遍,没发现什么语法错误呀,而且编译也通过了
一段Delphi代码,编译通过,运行时有异常

procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
username,apassword:String;
errcount:Integer;
begin
  errcount:=0;
  username := Edit1.Text;
  apassword := Edit2.Text;
  ADOQuery1.close;
  ADOQuery1.SQL.Clear;
  while(errcount<3) do
  begin
  ADOQuery1.SQL.Text:='select * from user where userno='''+username+''' and password='''+apassword+'''';
  ADOQuery1.open;
  if ADOQuery1.RecordCount=0 then
     begin
       errcount:=errcount+1;
       showMessage('用户名或密码错误,请重新输入');
       Edit1.Clear;
       edit2.Clear;
     end
    else
        begin
              ADOQuery1.SQL.Text:='select * from student where sno='''+username+'''';
              ADOQuery1.open;
              if ADOQuery1.RecordCount=0 then
                begin
                  ADOQuery1.SQL.Text:='select * from teacher where tno='''+username+'''';
                  ADOQuery1.open;
                   if ADOQuery1.RecordCount=0 then
                     begin
                      Form5.Show;
                      Form1.close;
                      end


                   else
                   begin
                      Form4.show;
                      Form1.Close;
                      end;
                 end
               else
                 begin
                   Form3.Show;
                   Form1.Close;
                 end;
              end;
        end;
         if errcount=3 then
          begin
            showMessage('连续三次密码错误,系统退出!');
            application.Terminate;
          end;

end;

[解决办法]
user可能是关键词,用[]把user包围了再试试看呢?
[解决办法]
ADOQuery1.SQL.Text:='select * from [user] where userno='''+username+''' and password='''+apassword+'''';

热点排行