L
lclin
Unregistered / Unconfirmed
GUEST, unregistred user!
我现有一个存放学生信息的表,字段有:sno(A)、sname(A)、sex(A)、photo(G),我想利用TQuery控件的SQL对Edit中输入的学号查找该学生的信息。我的查找按钮的Click
if box_sno.checked or box_sname.Checked or box_sex.checked
or box_photo.Checked or box_cno.checked or box_cname.checked
or box_teacher.checked or box_score.checked
then
begin
tag_field:=false;
with query1 do begin close;
with SQL do begin
clear;
add('select');
if box_sno.checked then
begin
add('student.sno');
tag_field:=true;
end;
if box_sname.checked then
begin
if tag_field then add(',');
add('student.sname');
tag_field:=true;
end;
if box_sex.checked then
begin
if tag_field then add(',');
add('student.sex');
tag_field:=true;
end;
if box_photo.checked then
begin
if tag_field then add(',');
add('student.photo');
tag_field:=true;
end;
if box_cno.checked then
begin
if tag_field then add(',');
add('class.cno');
tag_field:=true;
end;
if box_cname.checked then
begin
if tag_field then add(',');
add('class.cname');
tag_field:=true;
end;
if box_teacher.checked then
begin
if tag_field then add(',');
add('class.teacher');
tag_field:=true;
end;
if box_score.checked then
begin
if tag_field then add(',');
add('score.score');
end;
add('from student,class,score');
add('where student.sno=score.sno and class.cno=score.cno and student.sno=edit_sno.text');
end;
open;
end;
end
else showmessage('你还没选择字段,请选择。。。');
可是,当程序运行到student.sno=edit_sno.text后,就出了“Invalid
field name.text”错误。
诸位,谁有办法,在下将重金感谢!
if box_sno.checked or box_sname.Checked or box_sex.checked
or box_photo.Checked or box_cno.checked or box_cname.checked
or box_teacher.checked or box_score.checked
then
begin
tag_field:=false;
with query1 do begin close;
with SQL do begin
clear;
add('select');
if box_sno.checked then
begin
add('student.sno');
tag_field:=true;
end;
if box_sname.checked then
begin
if tag_field then add(',');
add('student.sname');
tag_field:=true;
end;
if box_sex.checked then
begin
if tag_field then add(',');
add('student.sex');
tag_field:=true;
end;
if box_photo.checked then
begin
if tag_field then add(',');
add('student.photo');
tag_field:=true;
end;
if box_cno.checked then
begin
if tag_field then add(',');
add('class.cno');
tag_field:=true;
end;
if box_cname.checked then
begin
if tag_field then add(',');
add('class.cname');
tag_field:=true;
end;
if box_teacher.checked then
begin
if tag_field then add(',');
add('class.teacher');
tag_field:=true;
end;
if box_score.checked then
begin
if tag_field then add(',');
add('score.score');
end;
add('from student,class,score');
add('where student.sno=score.sno and class.cno=score.cno and student.sno=edit_sno.text');
end;
open;
end;
end
else showmessage('你还没选择字段,请选择。。。');
可是,当程序运行到student.sno=edit_sno.text后,就出了“Invalid
field name.text”错误。
诸位,谁有办法,在下将重金感谢!