adoquery从数据库查询就可以了 with adoquery do begin close; sql.clear; sql.add('select × where 条件 from 表名') open; //循环得到相关的信息并写到listbox1控件中即可 end;
function TForm1.CheckUserLogin(sUserid,sPassword:string):Boolean; var sqlstr:string; begin if (Trim(sUserid)='') or (Trim(sPassword)='') then begin Application.MessageBox('请输入用户名或密码','系统提示',64) ; Result:=False; Exit; end; sqlstr:=' select * from UserManage where userid='''+sUserid+''' and '+ ' password='''+sUserid+''''; with ADOQuery1 do begin Close; SQL.Clear; SQL.Add(sqlstr); try Open; if RecordCount=1 then begin Result:=True; end else begin Application.MessageBox('用户名或者密码错误','系统提示',64) ; Result:=False; end; except Application.MessageBox('查询数据库异常','系统提示',64) ; Result:=False; end; end; end;
弄不懂
有没有具体代码
with adoquery do
begin
close;
sql.clear;
sql.add('select × where 条件 from 表名')
open;
//循环得到相关的信息并写到listbox1控件中即可
end;
var
sqlstr:string;
begin
if (Trim(sUserid)='') or (Trim(sPassword)='') then
begin
Application.MessageBox('请输入用户名或密码','系统提示',64) ;
Result:=False;
Exit;
end; sqlstr:=' select * from UserManage where userid='''+sUserid+''' and '+
' password='''+sUserid+'''';
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(sqlstr);
try
Open;
if RecordCount=1 then
begin
Result:=True;
end
else
begin
Application.MessageBox('用户名或者密码错误','系统提示',64) ;
Result:=False;
end;
except
Application.MessageBox('查询数据库异常','系统提示',64) ;
Result:=False;
end;
end;
end;