用ADO查询sql explor中的数据总是提示“不正常地定义参数对象,提供的参数信息不完整”
ADO中定义了id,xmzj两个参数为String型,代码:
  StrSql := 'Select * from table1 where ';
  if RBtn_Xmbh.Checked then
  begin
    StrSql := StrSql+'id=:id';
    ADOQuery1.Parameters.ParamByName('id').Value :=EDname.Text;
  end;
  if RBtn_Xmzj.Checked then
  begin
    StrSql := StrSql+'cost=:xmzj';
    ADOQuery1.Parameters.ParamByName('xmzj').Value :=EDname.Text;
  end;  ADOQuery1.Close;
  ADOQuery1.SQL.Clear ;
  ADOQuery1.SQL.Add(StrSql);不知何解?

解决方案 »

  1.   

    我觉得是sql语法的问题吧
    StrSql := 'Select * from table1';
    这样改试试,
      

  2.   

    用ADO查询sql explor中的数据总是提示“不正常地定义参数对象,提供的参数信息不完整”
    ADO中定义了id,xmzj两个参数为String型,代码:
    定义一个变量表示已加入过条件
      StrSql := 'Select * from table1 ';
      k := True;  if RBtn_Xmbh.Checked then
      begin
        if k = true then
        begin
          StrSql := StrSql+' WHERE ';
          StrSql := StrSql+'id=:id';
          k = false;
        end else
          StrSql := StrSql + 'and id=:id ';    ADOQuery1.Parameters.ParamByName('id').Value :=EDname.Text;
      end;
      if RBtn_Xmzj.Checked then
      begin
        if k = true then
        begin
          StrSql := StrSql+' WHERE ';
          StrSql := StrSql+'cost=:xmzj';
          k = false;
        end else
           StrSql := StrSql+'cost=:xmzj';
        ADOQuery1.Parameters.ParamByName('xmzj').Value :=EDname.Text;
      end;  ADOQuery1.Close;
      ADOQuery1.SQL.Clear ;
      ADOQuery1.SQL.Add(StrSql);
      

  3.   

    end else
           StrSql := StrSql+'cost=:xmzj';
    应该改为
        end else
           StrSql := StrSql+'and cost=:xmzj ';
      

  4.   

    同意楼上的
          StrSql := StrSql+' and cost=:xmzj ';and前也不能少空格。
      

  5.   

    我的条件都是独立的没有关联条件所以我不用and
      

  6.   

    id,const两个字段都是varchar型的
      

  7.   

    我知道错在哪了
    ADOQuery1.Parameters.ParamByName('id').Value :=EDname.Text;
    这句应该放在
    ADOQuery1.SQL.Add(StrSql);后面