procedure Tkh_cx.suiButton1Click(Sender: TObject);
var
 n1,n2,n3:string;
begin
 
 n1:=ADODataSet1.FieldList.Fields[10].FieldName;
 n2:=ADODataSet1.FieldList.Fields[11].FieldName;
 n3:=ADODataSet1.FieldList.Fields[12].FieldName;
 ADOQuery1.Close;
 ADOQuery1.SQL.Clear;
 ADOQuery1.SQL.Add('select * from kh where ['+n1+']=:yy  and ['+n2+']=:yy and ['+n3+']=:yy');
 ADOQuery1.Parameters.ParamByName('yy').Value:=suiEdit1.Text;
 ADOQuery1.Open;end;在执行查询时,为何不出现查询结果呀?我急呀.谢谢大家了.

解决方案 »

  1.   

    ADOQuery1.Parameters.ParamByName('yy').Value:=suiEdit1.Text;???
    这句话是干什么的?
    惨,刚学了几个月的delphi,现在一段时间没看,居然有些不懂!
      

  2.   

    可以试试所三个参数写成不同的,值可以一样 n1:=ADODataSet1.FieldList.Fields[10].FieldName;
     n2:=ADODataSet1.FieldList.Fields[11].FieldName;
     n3:=ADODataSet1.FieldList.Fields[12].FieldName;
     ADOQuery1.Close;
     ADOQuery1.SQL.Clear;
     ADOQuery1.SQL.Add('select * from kh where '+n1+'=:xx  and '+n2+'=:yy and '+n3+'=:zz');
     ADOQuery1.Parameters.ParamByName('xx').Value:=suiEdit1.Text;
    ADOQuery1.Parameters.ParamByName('yy').Value:=suiEdit1.Text;
    ADOQuery1.Parameters.ParamByName('zz').Value:=suiEdit1.Text;
     ADOQuery1.Open;
      

  3.   

    是不是ADOQuery1.Parameters.ParamByName('yy').Value:=suiEdit1.Text不对?
    value和Text不一定匹配阿
      

  4.   

    即使参数的值相同也要写三个参数
    参数名要不一样
    否则就不知道对应哪个参数了
    就象PJANE(PJ) 写的一样