我在做权限登录的时候出现了如下错误,请大家帮忙看看呀?
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.
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.
解决方案 »
- 请教一种SQL思路
- 在delphi中,怎样用一条词句操作access和sqlserver(不是本地的,是内网上其它一台电脑)两个数据库?
- 迷茫,散分……………………………………
- for i:=1 to (length(varpassword)/4 - 1) do错在哪
- 求教如何用语句判断一个创建了的临时表是否已经存在,急啊 在先等待!!
- ReportBuilder的字体问题!在线给分!
- 请问Splitter控件的具体用法
- 在一个窗体中如何调用另一个窗体返回的数据?最好不要用设全局变量的方法实现!
- dephi该怎么学呢?学哪本书好,需要pasca的基础吗?请高手指点,先谢了!!
- 再问一遍:TTreeView显示地区资料,数据库应如何处理?
- 如何访问oracle数据库中的数据表数据? -- 急!!!!
- 关于DBGrid的应用
第一个错误事你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'
二三 两个问题 你还是好好看看原程序 弄懂了 你就能解决了
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.我目前仅想做这个权限管理登录系统,接下来的代码晚上再来慢慢写了。大家先帮我看看这些了。。