分为老师、管理员和学生不同的登录权限,运行提示raised exception class EOleException with message '关键字'user'附近有语法错误。‘
但是检查了几遍,没发现什么语法错误呀,而且编译也通过了
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;

解决方案 »

  1.   

    我是菜鸟,之前也没学过Delphi,这学期数据库课程设计,要求用Delphi+SQL Server,但是很明显,我不会编~~~~~
      

  2.   

    user可能是关键词,用[]把user包围了再试试看呢?
      

  3.   

    ADOQuery1.SQL.Text:='select * from [user] where userno='''+username+''' and password='''+apassword+'''';
      

  4.   

    谢谢,问题已经解决了,除了user加方括号外,还有在while循环语句中缺少break跳出循环