以下是代码,帮帮忙看下吧procedure TLoginForm.Button1Click(Sender: TObject);
var
sqlStr:String;
beginif (IdEdit.Text='') or (PwEdit.Text='') then
begin
showmessage('请输入用户名和用户密码');
exit;
end;
with ADoQuery1 do
begin
close;
SQL.Clear;
sqlStr:='select * from 用户管理 where( ID='''+IdEdit.Text+''')and( PW='''+PwEdit.Text+''')';
SQL.Add(sqlStr);
ExecSQL;
if ADoQuery1.Recordset.RecordCount<>0 then
begin
LoginForm.Hide;
mainForm.ShowModal;
mainForm.Visible:=true;
LoginForm.Close;
end
else
begin
showmessage('用户'''+IdEdit.Text+'''是非法用户');
exit;
end;
end; end;procedure TLoginForm.Button2Click(Sender: TObject);
begin
close;
end;end.
var
sqlStr:String;
beginif (IdEdit.Text='') or (PwEdit.Text='') then
begin
showmessage('请输入用户名和用户密码');
exit;
end;
with ADoQuery1 do
begin
close;
SQL.Clear;
sqlStr:='select * from 用户管理 where( ID='''+IdEdit.Text+''')and( PW='''+PwEdit.Text+''')';
SQL.Add(sqlStr);
ExecSQL;
if ADoQuery1.Recordset.RecordCount<>0 then
begin
LoginForm.Hide;
mainForm.ShowModal;
mainForm.Visible:=true;
LoginForm.Close;
end
else
begin
showmessage('用户'''+IdEdit.Text+'''是非法用户');
exit;
end;
end; end;procedure TLoginForm.Button2Click(Sender: TObject);
begin
close;
end;end.
解决方案 »
- 记录类型问题
- DX紧急求救:线程的释放问题
- 怎样阅读已保存的报表(用delphi的quick report做的报表)
- 在Delphi中采用 dbgrid控件(或者DBEdit等其它控件) Insert 新记录时出错,而直接在ADOCommand里写Insert语句又正常呢?
- 我是利用TQuery组件通过设置SQL语言对数据库的数据查询和统计等等,我要写一篇课程设计报告,谁能帮帮我吗?
- 请教TPageControl控件
- 关于面向对象的问题!(简单)来的都有分!
- 怎样才可以得到当前操作系统的版本?
- 有长春人吗?加我好吗?我的Q:105923399
- 如何delphi通过bde的sql link连接oracle数据库,是否要安装一个oracle客户端
- TDatetime 字段中只存储了时间,为什么在DBGrid中显示确带有1899-12-30这个日期
- ADOQuery1状态判断
begin
close;
SQL.Clear;
sqlStr:= 'select * from 用户管理 where( ID= ' ' '+IdEdit.Text+ ' ' ')and( PW= ' ' '+PwEdit.Text+ ' ' ') ';
SQL.Add(sqlStr);
open;//
end;//
if ADoQuery1.Recordset.RecordCount < >0 then
begin
LoginForm.Hide;
mainForm.ShowModal;
mainForm.Visible:=true;
LoginForm.Close;
end
else
begin
showmessage( '用户 ' ' '+IdEdit.Text+ ' ' '是非法用户 ');
exit;
end;
//end;
一般是用来之行sql 的比如 insert,update 等没返回数据集的sql语句。 open
用来有返回数据集的sql语句。
如果我在IdEdit或者PwEdit里头输入 or 1>0,你的帐号密码验证这条防线就失去了意义。帐号密码验证方式应该是根据用户帐号名称,取出帐号及密码,然后做校验。
xxx' or 1>0 or ID='xxx
xxx' or 1>0 or PW='xxx
校验还有意义吗?如下:
strSql := 'select * from 用户管理 where(ID= ''xxx'' or 1>0 or ID=''xxx'')and
(PW=''xxx'' or 1>0 or PW=''xxx''';