我在做权限登录的时候出现了如下错误,请大家帮忙看看呀?
Build
  [Error] login.pas(56): Undeclared identifier: 'loPartialKey'
  [Error] login.pas(56): Incompatible types: 'TLocateOption' and 'Integer'
  [Error] login.pas(56): Incompatible types: 'TLocateOption' and 'Integer'
  [Fatal Error] Stu_mis.dpr(9): Could not compile used unit 'login.pas'并且怎么提示说在编译Stu_Mis工程时还有不能编译login单元呀?哪位大侠帮我看看呀。。我的login单元代码是这样写的:
unit login;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, jpeg, ExtCtrls;type
  Tfrmlogin = class(TForm)
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure ComboBox1DropDown(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  frmlogin: Tfrmlogin;
  ilogin:integer;
  //ilogin:=0;//初始化记录登录次数的参数;
implementationuses DM, main;{$R *.dfm}procedure Tfrmlogin.BitBtn2Click(Sender: TObject);
begin
application.Terminate;
end;procedure Tfrmlogin.BitBtn1Click(Sender: TObject);
var
password,username:string;
begin
 username:=combobox1.Text ; //用户名;
 password:=edit1.Text;   //用户密码;
 ilogin:=0;
 inc(ilogin);
 if combobox1.Items.Count>0 then
  begin
   combobox1.ItemIndex:=0;
   with Dm.DataMD.ADOlogin do
     begin
     //当用户名和密码均合法,且登录次数小于三次是才登录成功;
     if locate('用户名',username,[loPartialKey]) and locate('密码',password,[loPartialKey]) and (ilogin<4) then
       begin
       close;
       sql.Clear ;
       sql.add('select * from login where 用户名='''+username+''''+' and 密码='''+password+'''');
       open;
       application.CreateForm(Tfrmmain,frmmain);
       frmmain.StatusBar1.Panels.Items[1].Text:=username;
       frmmain.StatusBar1.Panels.Items[3].text:=fieldbyname('权限').AsString;
       if fieldbyname('权限').AsString='操作员' then
         begin
           with frmmain do
            begin
             frmmain.N9.Enabled:=false;
             frmmain.N10.Enabled:=false;
            end
         end;       frmlogin.ShowModal;
       frmlogin.Free ;
       frmmain.ShowModal ;
       frmmain.Free ;
       end
     else //当用户名和密码不正确是显示;
       begin
         if messagedlg('请重新输入用户名和密码',mtconfirmation,[mbyes,mbno],0)=mryes then
         begin
         edit1.Clear ;
         edit1.SetFocus ;
        
       end
       else
         close;
     end;
     if ilogin>3 then   //当错误次数达三次以上则不让用户使用该软件;
      begin
      showmessage('你输入的密码超过三次了,你无法使用莫理I的学生管理软件');
      application.Terminate ;
      end;
    end;
end
else
  showmessage('数据库中没有该名字,请先注册使用');
end;
procedure Tfrmlogin.ComboBox1DropDown(Sender: TObject);
var
 i:integer;
begin
 //请用户先从下表框中选择己存在的用户名;
  combobox1.Clear ;
  with DM.DataMD.ADOlogin do
  begin
  close;
  sql.Clear ;
  sql.Add('select * from login');
  open;
  if recordcount>0 then
  begin
  first;
  for i:=0 to recordcount-1 do
   begin
    combobox1.Items.Add(fieldbyname('用户名').AsString);
    next;
   end;
  end
else
 showmessage('当前还没有该用户,请先注册');
    end;
  end;
end.

解决方案 »

  1.   

    你得代码事copy别人得吧。
    第一个错误事你loPartialKey变量没有定义
    二三都是类型不匹配,你copy得时候得copy完全一点啊[Error] login.pas(56): Undeclared identifier: 'loPartialKey'
      [Error] login.pas(56): Incompatible types: 'TLocateOption' and 'Integer'
      [Error] login.pas(56): Incompatible types: 'TLocateOption' and 'Integer'
      [Fatal Error] Stu_mis.dpr(9): Could not compile used unit 'login.pas'
      

  2.   

    To yurenjf(极限),谢谢你的提醒,里面没有与数据库关联,刚刚加进去了。编译通过了呵呵。但在输入正确的用户名和密码后又弹出另一个错误了。
      

  3.   

    第一个问题 好解决  如果它是局部变量 可以在该过程的begin 上面定义一下就可以了
    二三 两个问题 你还是好好看看原程序 弄懂了 你就能解决了
      

  4.   

    这几个错误都是由于没有与数据库关联引起的,我刚刚忘了加进DB进去,楼上的兄弟有提出来了,但现在就是在正确登录后不能调入main窗口了,不知道怎么回事,出现了异常,,有哪位能帮我看看吗。我给源程序你看。。贴出来也行。。
      

  5.   

    整个程序的代码如下:工程文件Stu_Mis
    program Stu_mis;uses
      Forms,
      splash in 'splash.pas' {splashform},
      DM in 'DM.pas' {DataMD: TDataModule},
      about in 'about.pas' {AboutBox},
      login in 'login.pas' {frmlogin},
      main in 'main.pas' {frmmain};{$R *.res}begin
      Application.Initialize;
      application.Title:='学生管理系统';
      Application.CreateForm(Tsplashform, splashform);
      Application.CreateForm(TDataMD, DataMD);
      Application.CreateForm(TAboutBox, AboutBox);
      Application.CreateForm(Tfrmlogin, frmlogin);
      Application.CreateForm(Tfrmmain, frmmain);
      Application.Run;
    end.
    main 单元还没有写代码:
    unit main;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Menus, ComCtrls, XPMenu, ToolWin, ImgList;type
      Tfrmmain = class(TForm)
        MainMenu1: TMainMenu;
        N1: TMenuItem;
        N2: TMenuItem;
        N3: TMenuItem;
        N4: TMenuItem;
        N5: TMenuItem;
        N6: TMenuItem;
        N7: TMenuItem;
        N8: TMenuItem;
        N9: TMenuItem;
        N10: TMenuItem;
        N11: TMenuItem;
        N12: TMenuItem;
        N13: TMenuItem;
        N14: TMenuItem;
        N15: TMenuItem;
        N16: TMenuItem;
        N17: TMenuItem;
        ImageList1: TImageList;
        CoolBar1: TCoolBar;
        ToolBar1: TToolBar;
        ToolButton1: TToolButton;
        ToolButton2: TToolButton;
        ToolButton3: TToolButton;
        ToolButton4: TToolButton;
        StatusBar1: TStatusBar;
        ToolButton5: TToolButton;
        ToolButton6: TToolButton;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      frmmain: Tfrmmain;implementationuses login, about;{$R *.dfm}end.DM数据模块:
    unit DM;interfaceuses
      SysUtils, Classes, DB, ADODB;type
      TDataMD = class(TDataModule)
        ADOConn: TADOConnection;
        ADOlogin: TADOQuery;
        Dlogin: TDataSource;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      DataMD: TDataMD;implementation{$R *.dfm}end
    splash窗体:
    unit splash;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls, jpeg;type
      Tsplashform = class(TForm)
        Image1: TImage;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Timer1: TTimer;
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      splashform: Tsplashform;implementationuses login;{$R *.dfm}procedure Tsplashform.Timer1Timer(Sender: TObject);
    begin
    application.CreateForm(Tfrmlogin,frmlogin);
    splashform.Hide ;
    splashform.Free ;
    frmlogin.ShowModal ;
    end;end.我目前仅想做这个权限管理登录系统,接下来的代码晚上再来慢慢写了。大家先帮我看看这些了。。