用sqlparameter吧,如果要用sql string,在datastart.value.toshortdatestring()前后加上"#"符号试试

解决方案 »

  1.   

    athossmth(athos):
    我试了一下,结果不对
      

  2.   

    "select 日期 from ChuShiXinXi where 日期>='"+dateStart.Value.ToShortDateString("yyyy-MM-dd")+"' and 日期<='"+dateEnd.Value.ToShortDateString("yyyy-MM-dd") + "'";
      

  3.   

    "select 日期 from ChuShiXinXi where 日期>='"+dateStart.Value.ToShortDateString("yyyy-MM-dd")+"' and 日期<='"+dateEnd.Value.ToShortDateString("yyyy-MM-dd") + "'";
      

  4.   

    "select 日期 from ChuShiXinXi where 日期>='"+dateStart.Value.ToShortDateString("yyyy-MM-dd")+"' and 日期<='"+dateEnd.Value.ToShortDateString("yyyy-MM-dd") + "'";
      

  5.   

    xieshy(金刚树):
    我试了一下,还是有问题ToShortDateString()是没有参数的.
      

  6.   

    问一下你用的什么数据库??
    SQLserver和Oracle处理可不一样哦!!
    Oracle:
    "select 日期 from ChuShiXinXi where 日期>=To_Date('"+dateStart.Value+"','yyyy-mm-dd') and 日期<=To_Date('"+dateEnd.Value+"','yyyy-mm-dd')";SQLserver:
    "select 日期 from ChuShiXinXi where 日期>='"+dateStart.Value.ToShortDateString()+"' and 日期<='"+dateEnd.Value.ToShortDateString()+"';
      

  7.   

    sql server可以把日期当作字符串用
    "日期 <= '" +dateTime.value.ToString("yyyy-MM-dd") + "'";