with adoqeury1 do begin close; sql.text:='select * from 你的表名 where [学号]='+QuotedStr(trim(edit1.text)); open; edit2.text:=FieldValues['姓名']; end;
或者: with adoqeury1 do begin close; sql.text:='select * from 你的表名 where [学号]='''+trim(edit1.text)+''''; open; edit2.text:=FieldValues['姓名']; end;
按照两位的方法,出现一个同样的错误 could not conert variant of type(Null) into type(string)'.process stopped .
字段要对应好 你查出来的值是空 不能赋值给edit
with adoqeury1 do begin close; sql.text:='select * from 你的表名 where [学号]='+QuotedStr(trim(edit1.text)); open; if not adoquery1.FieldByName('姓名').IsNull then edit2.text:=FieldValues['姓名']; end;
close;
sql.text:='select * from 你的表名 where [学号]='+QuotedStr(trim(edit1.text));
open;
edit2.text:=FieldValues['姓名'];
end;
close;
sql.text:='select * from 你的表名 where [学号]='''+trim(edit1.text)+'''';
open;
edit2.text:=FieldValues['姓名'];
end;
could not conert variant of type(Null) into type(string)'.process stopped .
with adoqeury1 do begin
close;
sql.text:='select * from 你的表名 where [学号]='+QuotedStr(trim(edit1.text));
open;
if not adoquery1.FieldByName('姓名').IsNull then
edit2.text:=FieldValues['姓名'];
end;