rq:=query2.fieldvalues['测试日期']; SQLstr:=‘delete from table where 测试日期=cast('''+datetostr(rq)+''' as datetime) '
尝试: SQLstr:='delete from table where 测试日期='''+Cast(datetostr(rq) as date)+'''';SQLstr:='delete from table where 测试日期='+datetostr(rq);
用的cb或delphi吗?先把rq转换成字符串rq_str(cb 中) 然后再 SQLstr:='delete from table where 测试日期='''+Cast(rq_str as date)+'''';
直接用:delete from table where 测试日期=''' + rq + ''''
以上都有试了同样的错误“type mismatch in expression"是不是这个原因,其实完整的语句是:SQLstr:='delete from '''+tempcx+''' where 编号='''+bh+''' and 测试日期='''+datetostr(rq)+'''';高手在那???????????拜托各位了,实在是急啊
SQLstr:=‘delete from table where 测试日期=cast('''+datetostr(rq)+''' as datetime) '
SQLstr:='delete from table where 测试日期='''+Cast(datetostr(rq) as date)+'''';SQLstr:='delete from table where 测试日期='+datetostr(rq);
然后再
SQLstr:='delete from table where 测试日期='''+Cast(rq_str as date)+'''';
第二你最好把SQLSTR打出来给大家看看,因为你又是单引号又是两个单引号的我觉得可能最后是引号出了问题
第三,可能是datetostr(rq)的输出结果不是一个日期
SQLstr:='delete from where 测试日期='''+rq+'''';
把SQL语句至当作是一个字符串,没有变量!
SQLstr:='delete from '+ tempcx + ' where 编号 = ''' + bh + ''' and 测试日期=''' + datetimetostr(rq,'yyyy-mm-dd') + '''';
你试试