如Sql语句:
  select * from a join b on a.id=b.id
where a.date>:Date and b.Date>:Date两个参数重名,用paramByName赋值只能给其中的一个赋值,请问有什么方法可以赋一值。因为程序中的参数个数是不一定的,所以不能通过索引+名字的方式遍历参数。

解决方案 »

  1.   

    a.data>: aData and b.Date>:bDate 
    把参数名区别开不就行了
      

  2.   

    这样可以
    sql.add('where a.date>:Date');
    Parameters.ParamByName('Date').vaule:='...';
    sql.add('b.date>:Date');
    Parameters.ParamByName('Date').vaule:='...';
      

  3.   

    Delphi中参数真不太好用,唉!
      

  4.   

    params[0].value:=xxxparams[1].value:=xxxx这样就可以区分了啊
      

  5.   

    可以参考:http://topic.csdn.net/u/20090510/17/4f47f460-e5c4-4926-bd5f-1911695398d8.html
      

  6.   


    做下修改啊   query1.Params.Items[0].value:=123;
       query1.Params.Items[1].value:=234;  这样就可以  
       
      

  7.   

    是可以。我的查询可能是这样的
    select ... from 
    where di_time<=:date ....
    union 
    select ... from ...
    where di_time<=:date and ...不能一项项地加参数。条件是不固定的,
    也可能只有一个select
    我想用参数来完成,但通过参数名赋值,只有第一个参数赋值了。通过循环判断参数的名称,太笨了。大家有没有好的方法?