做登陆窗体时候加了个combobox控件

xiaohuanbaby 2007-04-21 03:56:56
做登陆窗体时候加了个combobox控件;
下面是我的代码:
procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from 管理员表 where 用户名=:na ,权限=:sa and 密码=:pa');
parameters.ParamByName('na').Value:=edit1.Text;
parameters.ParamByName('pa').Value:=edit2.Text;
open;
if recordcount=0 then
begin
application.MessageBox('您输入的用户名或密码不正确,请重新输入!','系统提示',0+64);
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
exit;
但是权限不知道改怎么处理,谁能告诉我填加什么代码?
...全文
189 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
IDWB 2007-04-22
  • 打赏
  • 举报
回复
procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from 管理员表 where 用户名=:na ,权限=isnull(:sa,权限) and 密码=:pa');
parameters.ParamByName('na').Value:=edit1.Text;
parameters.ParamByName('pa').Value:=edit2.Text;
open;
if recordcount=0 then
begin
application.MessageBox('您输入的用户名或密码不正确,请重新输入!','系统提示',0+64);
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
exit;
lihuasoft 2007-04-22
  • 打赏
  • 举报
回复
sql.Add('select * from 管理员表 where (用户名=:na) and (权限=:sa) and (密码=:pa)');
parameters.ParamByName('na').Value:=QuotedStr(edit1.Text);
parameters.ParamByName('sa').Value:=IntToStr(Combobox1.ItemIndex);
parameters.ParamByName('pa').Value:=QuotedStr(edit2.Text);
open;
if recordcount<1 then
begin
application.MessageBox('用户名/密码不正确或无此权限,请重新输入!','系统提示',0+64);


不一定对,试试看
xiaohuanbaby 2007-04-22
  • 打赏
  • 举报
回复
没人回复,自己给自己顶一下.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧