比如我用ADOQUERY1连接TABLE1,TABLE1大致如下:
Name PassWord
AAA 123
BBB 456
CCC 789
...
--------------------------------------------------
现在比如Edit1.text:='BBB';
在Edit2中输入数据。然后比较此记录的PassWord是否正确,若正确则YESNO为真,否则为假。
Name PassWord
AAA 123
BBB 456
CCC 789
...
--------------------------------------------------
现在比如Edit1.text:='BBB';
在Edit2中输入数据。然后比较此记录的PassWord是否正确,若正确则YESNO为真,否则为假。
begin
ADOQUERY1.Locate('Name',Edit1.text,[loCaseInsensitive,loPartialKey]);
if Edit2.Text<>ADOQUERY1['PassWord']
then
begin
Application.MessageBox('密码错误!','错误',MB_ICONERROR + MB_OK);
Exit;
end
else
begin
...//do something;
end;
end;
if Edit2.Text = FieldByName('PassWord').AsString then ...
if adoquery1.recordcount<>0 then
yesno=true
else
yesno=false;
假设edit2放的是用户名
adoquery1.sql.text:='select password from table1 where name='+''''+edit2.text+''''+'and password='+''''+edit1.text+'''';
adoquery1.open;
if adoquery1.recordcount<>0 then
yesno=true
else
yesno=false;
假设edit2放的是用户名
adoquery1.sql.text:='select count(*) from table1 where name='+''''+edit2.text+''''+'and password='+''''+edit1.text+'''';
adoquery1.open;
if adoquery1.fields[0].asinteger<>0 then
yesno=true
else
yesno=false;
假设edit2放的是用户名
我不想用SQL语句的,Filter行不行呢。
是一个定位函数,不是SQL语句。
str1, str2: String;begin
with adoquery1 do
begin
Active := False;
sql.text:='select password from table1 where name=:str1 and password=:str2';
Parameters[0].value := edit1.text;
Parameters[1].Value := edit2.text;
Active := true;
if recordcount>0 then
yesno=true
else
yesno=false;
end;
end;
我不想用SQL语句的,Filter行不行呢。
var
str1, str2: string;begin
str1 := 'name';
str2 := 'password';
with adoquery1 do
begin
..............
filtered := true;
filter:='str1='+''''+edit2.text+''''+'and str2='+''''+edit1.text+'''';
if recordCount>0 then
yesno=true
else
yesno=false;
end;
end;