命令对象不是有个让你指定选择数据的sql语句吗?
如select a,b,c from table where id>?
虽然用'?'可以动态传参数。但如果我的where 后的条件个数是不定的,怎么办呢。
比如有时是select a,b,c from table where id>?
有时是select a,b,c from table where id>? and name=?
如果可以在程序中动态指定这个sql语句就好了,但是不行。
有没有好的解决办法啊?!

解决方案 »

  1.   

    打条件设为STR1,针对STR1赋值不行吗?
    如你上例:
    1.str1="id>?"
    2.str1="id>? and name=?"
      

  2.   

        If DataEnv.rsCmd_unit.State = adStateOpen Then DataEnv.rsCmd_unit.Close
        DataEnv.Commands("Cmd_unit").CommandText = "select " & TableName & ".* from " & TableName
        DataEnv.Cmd_unit
      

  3.   

    select a,b,c from table where id>'" & ? & "'
    select a,b,c from table where id>'" & ? & "' and name='" & ? & "'