czpsql1:= 'SELECT * FROM 操作票表 where ' +
'厂站号 = '+inttostr(Datacon.g_bdzbh)+' '+
' and 类型 = '+inttostr(Datacon.g_lxbh)+' ' +
' and 保存时间 like '''+trim(Datacon.g_year)+'-'+trim(Datacon.g_mou)+'-'+trim(Datacon.g_date)+'%'''+
' order by 序号';时间查不出来,执行后没有结果
'SELECT * FROM 操作票表 where 厂站号 = 0 and 类型 = 1 and 保存时间 like '2003-07-1%' order by 序号'
'厂站号 = '+inttostr(Datacon.g_bdzbh)+' '+
' and 类型 = '+inttostr(Datacon.g_lxbh)+' ' +
' and 保存时间 like '''+trim(Datacon.g_year)+'-'+trim(Datacon.g_mou)+'-'+trim(Datacon.g_date)+'%'''+
' order by 序号';时间查不出来,执行后没有结果
'SELECT * FROM 操作票表 where 厂站号 = 0 and 类型 = 1 and 保存时间 like '2003-07-1%' order by 序号'
Datacon.g_bdzbh
Datacon.g_lxbh
Datacon.g_year
Datacon.g_mou
Datacon.g_date
你可以
1 用 convert(varchar,保存时间,120) like '2003-07-1%'
2 或者
'SELECT * FROM 操作票表 where 厂站号 = 0 and 类型 = 1 and 保存时间 between '2003-7-10' and '2003-7-20' order by 序号'
where 厂站号 = '0'
and 类型 = '1'
and 保存时间 like '2003-07-1%'
order by 序号这样行吗?
建议你先使用数据库的相关执行SQL语句工具(ORACLE--SQLPLUS)试验一下生成的SQL语句,然后改进。
Datacon.g_lxbh
Datacon.g_year
Datacon.g_mou
Datacon.g_date我是字符, Datacon.g_year :=combobox2.Text ; //年
Datacon.g_mou :=combobox3.Text ; //月
Datacon.g_date :=SpinEdit1.Text ; //日