我想用sql语句把datetimepicker中的日期插入到数据库中表的某个字段。
query1.SQL.add('update gz_jbqk set time=to_date(datetimepicker1.datetime,''yyyy-mm'')');
可为何执行不了?

解决方案 »

  1.   

    query1.SQL.add('insert into gz_jbqkyue as select * from gz_jbqk');
    这句为何提示说缺少关键字?(表的复制)
      

  2.   

    可一个月只能做一次。意思就是判断datetimepicker1中的日期(取到月)与库中的日期(取到月),如果有相同的就退出,没有就插入。怎么实现?最好有段代码
      

  3.   

    那肯定不行,因为“yyyy-mm”不是一个合法的日期型值。除非time字段是字符型。
      ADODataSet1.Active:=false;
      ADODataSet1.CommandText:='select * from gz_jbqkyue where month(time)=month(getdate())'
      ADODataSet1.Active:=true;
      if ADODataSet1.IsEmpty then
        begin
        ...
        插入记录
        ...
        end;