| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 756 人关注过本帖
标题:登录代码怎么写????
只看楼主 加入收藏
xytkf
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2006-5-11
收藏
 问题点数:0 回复次数:2 
登录代码怎么写????

做了一个界面不能运行代码出现错误啦...........
前台是两个字段用户名(EmployeeName),密码(Passwd):char
在确定的ONCLICK那里写代码
如下:
procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
if (Edit1.Text <>'') and (Edit2.Text <>'') then
begin
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select *from EmployeeInfo where EmployeeName:=Edit1.Text and Passwd:=Edit1.Text');
//Parameters.FieldByName('employname').AsString :=Edit1.Text;
//parameters.FieldByName('password').AsString :=Edit2.Text;
Open;
if Eof then
begin
logTime := logTime+1;
if messagebox(handle,'您填写的用户名或密码不正确,是否重新输入!','出错提示',
Mb_IconInformation+Mb_Okcancel) = idcancel then
Application.Terminate;
if logTime >2 then
begin
messagebox(handle,'对不起,登录次数超过三次程序自动关闭!','非法登录',
Mb_Iconwarning+Mb_Ok);
Application.Terminate;
end;
end
else
begin

case FieldByName('LevelId').AsInteger of
0:begin
mainform.N16.Enabled:=false;
MAINFORM.N21.Enabled:=false;
end;
1:begin
MAINFORM.N9.Enabled:=false;
MAINFORM.N10.Enabled:=false;
end;
2:begin
MAINFORM.N6.Enabled:=false;
MAINFORM.N16.Enabled:=false;
MAINFORM.N7.Enabled:=false;
end;

end;
END;
END;END;END;
END.

运行会一时出错啊@!!
好像下面就是问题的错误所在:

SQL.Add('select *from EmployeeInfo where EmployeeName:=Edit1.Text and Passwd:=Edit1.Text');
//Parameters.FieldByName('employname').AsString :=Edit1.Text;
//parameters.FieldByName('password').AsString :=Edit2.Text;
Open;

搜索更多相关主题的帖子: SQL begin 代码 EmployeeName Passwd 
2006-09-27 18:52
volte
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:69
帖 子:1167
专家分:1316
注 册:2004-12-19
收藏
得分:0 
SQL.Add('select * from Employee');
SQL.Add('where EmployeeName = ' + Edit1.Text);
SQL.Add('and Passwd = ' + Edit1.Text);
Open;


上面的换成这句话!

大家都是朋友,有空就来坐坐!
2006-09-28 20:27
lcy2003
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-8-17
收藏
得分:0 
try this :
SQL.Add('select * from EmployeeInfo where EmployeeName:='''+trim(Edit1.Text)+''' and Passwd:='''+trim(Edit1.Text)+'''');
2006-09-29 15:16
快速回复:登录代码怎么写????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015279 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved