SQL查询,where里面是否可以接页面参数例如:页面中定义:datetime dt= "2008-1-18";
页面中查询,想用上面的参数来做条件
select *
from 表
where 时间>=dt ;
可以这样用吗?
那写法这样写呢?

解决方案 »

  1.   

    string strsql="select   * 
    from   表 
    where   时间>'"+dt+"'";
      

  2.   

    可以啊,如下:
    "select * from 表 where 数据库中时间字段> ='"+dt+"'"   ;
      

  3.   


    string   strsql="select       *   
    from       表   
    where       时间>= '"+dt+"'";
      

  4.   

    select * from 表  where 时间 >= '"+dt+"'
      

  5.   

    select   * 
    from   表 
    where   时间>= '"+dt+"'  
      

  6.   

    还有用存储过程写 ,楼上的正确
    select * from 表 where 时间>="+dt