select * from tbl where chrappenddate='" + DTPbegintime.Value + " '
我用這個語句進行日期條件查詢﹐可是總是出現類型不匹配的錯誤提示。
 DTPbegintime 是DTPicker控件﹐控件中的日期類型是2004/10/22.chrappenddate字段里的存的時間是2004-10-22 04:07:13.000這種類型.
 請問要怎么樣才能正確運行

解决方案 »

  1.   

    select * from tbl where chrappenddate='" & DTPbegintime.Value & " '
      

  2.   

    select * from tbl where chrappenddate=CONVERT(DATETIME,'" & DTPbegintime.Value & " ',120)"
      

  3.   

    DTPbegintime.value应写为'"& DTPbegintime.value &"'也就是加上一对''
      

  4.   

    "select * from tbl where chrappenddate='" + format(DTPbegintime.Value,"YYYY-MM-DD") + "'"
      

  5.   

    能解釋一下CONVERT(DATETIME,'" & DTPbegintime.Value & " ',120)"的具體意識嗎,特別 是120的意識
      

  6.   

    SQL数据库不能用Format函数,只能用CONVERT函数格式化时间。查看一下SQL帮助,上面祥细的解释