我在做一个考试软件的时候,我要每个考生相应的结果得数插入到考生表中某个字段,应该如何来实现,下面语句有哪里不对请指点一下 adoquerytest.close;
adoquerytest.SQL.Clear;
adoquerytest.SQL.Add('select * from test where name = ''+frmtest.edit1.text+''') ;
adoquerytest.ExecSQL;
adoquerytest.open;
adoquerytest.edit;
adoquerytest.fieldByName('df').value := trim(label2.Caption);
adoquerytest.Post;
adoquerytest.SQL.Clear;
adoquerytest.SQL.Add('select * from test where name = ''+frmtest.edit1.text+''') ;
adoquerytest.ExecSQL;
adoquerytest.open;
adoquerytest.edit;
adoquerytest.fieldByName('df').value := trim(label2.Caption);
adoquerytest.Post;
单引号的问题.有时看的眼花,所以我一般
sqltext:='select * from test where name = "'+frmtest.edit1.text+'"';
再sqltext:=AnsiReplaceStr(str,'"',#39);
adoquerytest.close;
adoquerytest.SQL.Clear;
adoquerytest.SQL.Add('update test set df='''+label2.Caption+''' where name= ''+frmtest.edit1.text+''') ;
adoquerytest.ExecSQL;
看你那样写,看来df字段应该是字符型才可以,如果df字段不是字符型,要先把label2.Caption进行输入检查并转换为数值型,再用上面的句子。