edouserid:=username.Text;
edopassword:=password.Text;
with adoquery1 do
begin
close;
sql.Text:='select * from userdata where userid=edouserid';
open;
if eof then
ShowMessage('无该用户!');
if adoquery1.FieldByName('password').AsString<>edopassword then
ShowMessage('密码不对!');
end;
end;
运行时提示edouseerid没有默认值。
edopassword:=password.Text;
with adoquery1 do
begin
close;
sql.Text:='select * from userdata where userid=edouserid';
open;
if eof then
ShowMessage('无该用户!');
if adoquery1.FieldByName('password').AsString<>edopassword then
ShowMessage('密码不对!');
end;
end;
运行时提示edouseerid没有默认值。
edopassword:=password.Text;
with adoquery1 do
begin
close;
sql.Text:=format('select * from userdata where userid=''%s''',[edouserid]));
open;
if eof then
ShowMessage('无该用户!');
if adoquery1.FieldByName('password').AsString<>edopassword then
ShowMessage('密码不对!');
end;
edopassword:=password.Text;
with adoquery1 do
begin
close;
sql.Text:='select * from userdata where userid=:edouserid'; // :edouserid
Parameters.ParamByName('edouserid').Value:=edouserid;
open;
if eof then
ShowMessage('无该用户!');
if adoquery1.FieldByName('password').AsString<>edopassword then
ShowMessage('密码不对!');
end;
end;
edopassword:=password.Text;
with adoquery1 do
begin
close;
sql.Text:='select * from userdata where userid='''+edouserid+'''';//UserID为字符类型
或sql.Text:='select * from userdata where userid='+edouserid+'';//UserID为数字类型
open;
if eof then
ShowMessage('无该用户!');
if adoquery1.FieldByName('password').AsString<>edopassword then
ShowMessage('密码不对!');
end;
end;
edopassword:=password.Text;
with adoquery1 do
begin
close;
sql.clear;
sql.Text:='select * from userdata where userid=:edouserid';
sql.add(sql.text);
Parameters.ParamByName('edouserid').Value:=edouserid;
open;
if eof then
ShowMessage('无该用户!');
if adoquery1.FieldByName('password').AsString<>edopassword then
ShowMessage('密码不对!');
end;
end;