delphi 登陆界面后显示主界面,帮我看下问题出在那了?
这是登陆界面,主要代码如下procedureTForm2.Button1Click(Sender:TObject);varname,password,sqlstr:str...
这是登陆界面,主要代码如下
procedure TForm2.Button1Click(Sender: TObject);var name,password,sqlstr:string;begin if (length(trim(edit1.Text))>0) or (length(trim(edit2.Text))>0) then begin name:=trim(edit1.Text); //取得用户输入的用户名 password:=trim(edit2.Text); //取得用户输入的密码 sqlstr:='select * from t_user where (username='''+name+''') and(userpass='''+password+''')'; with Tadoquery.create(nil) do try connection:=form1.adoconnection1; close; sql.clear; sql.add(sqlstr); open; if recordcount>0 then begin form2.close; showmessage('登陆成功'); form1.show; end else begin showmessage('用户名密码错误'); edit1.SetFocus; edit1.SelectAll; end;
finally free; end;
end else begin showmessage('请输入用户名密码'); edit1.SelectAll; end;end;
procedure TForm2.Button2Click(Sender: TObject);beginclose;end
错误提示如下
求解释错哪里?怎么改? 展开
procedure TForm2.Button1Click(Sender: TObject);var name,password,sqlstr:string;begin if (length(trim(edit1.Text))>0) or (length(trim(edit2.Text))>0) then begin name:=trim(edit1.Text); //取得用户输入的用户名 password:=trim(edit2.Text); //取得用户输入的密码 sqlstr:='select * from t_user where (username='''+name+''') and(userpass='''+password+''')'; with Tadoquery.create(nil) do try connection:=form1.adoconnection1; close; sql.clear; sql.add(sqlstr); open; if recordcount>0 then begin form2.close; showmessage('登陆成功'); form1.show; end else begin showmessage('用户名密码错误'); edit1.SetFocus; edit1.SelectAll; end;
finally free; end;
end else begin showmessage('请输入用户名密码'); edit1.SelectAll; end;end;
procedure TForm2.Button2Click(Sender: TObject);beginclose;end
错误提示如下
求解释错哪里?怎么改? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询