使用参数方法,这样在delphi中你不会因为使用不同的数据库系统而修改程序.

解决方案 »

  1.   

    方法如下:
    select * from table where f1>:dDate
    然后在数据集控件打开之前,对参数赋值即可.parambyname('dDate').AsDatetime := ....'
      

  2.   

    ('select * from zz_info 
    where 子段 between #'+datetostr(DateTimePicker1.datetime)+'# and #'+datetostr(DateTimePicker2.datetime)+'#');

    select * from table where f1>#12:12:12#
      

  3.   

    针对Access数据库SQL语句的时间要用 # 号引
    针对MSSQL数据库SQL语句的时间要用 ' 号引
    别忘了给分哦!!!
      

  4.   

    上面的方法根据具体的数据库还要去改变日期值.其实你先将此时间字符串转换为TDatetime型ddDate,然后sql语句如下:
    select * from table where f1>:dDate;
    另外在open之前,parambyname('dDate').AsDatetime := ddDate;然后open即可不管你用的是什么数据库,这方法均适用.
      

  5.   

    TO  menliwxj(有缘) 
    你有没有用过ACCESS的数据库呀!这样能查出时间吗??
    你试试看
      

  6.   

    和SQL Server上面有些不同的SQL Server写入的时候最好使用引号!
      

  7.   

    用#号括起来不行呀,我在ACCESS数据库中建的字段是一个既有日期又有时间的,我在日期和时间两边用#好括了,可是在时间和日期中间我用了个空格不知道怎么不行,原语如下:
    SQL.add('select * from AlarmTable where Alarm_DateTime>=#'+Combobox7.text+'-'+Combobox8.Text+'-'+Combobox9.text+''+combobox10.text+':'+combobox11.text+':'+combobox12.text+'# and Alarm_DateTime<=#'+Combobox13.text+'-'+Combobox14.Text+'-'+Combobox15.text+''+combobox16.text+':'+combobox17.text+':'+combobox18.text+'#');
      

  8.   

    select * from table where f1>#12:12:12#