我用query1查询某一段时间内库存量,起史时间分别由两个combobox输入?代码如下:
if (combobox1.text)<>'' and (combobox2.text)<>'' then
begin
query1.close;
query1.sql.clear;
query1.sql.add('select *from abc where date between '''+combobox1.text+''' and '''+combobox2.text+'''');
query1.execsql;
query1.open;
end;
以上的语句是不是有问题啊为什么总是出现operator not applicable to this operand type这样的信息啊?郁闷啊?不知道怎么修改?请各位大侠帮帮小第吧
if (combobox1.text)<>'' and (combobox2.text)<>'' then
begin
query1.close;
query1.sql.clear;
query1.sql.add('select *from abc where date between '''+combobox1.text+''' and '''+combobox2.text+'''');
query1.execsql;
query1.open;
end;
以上的语句是不是有问题啊为什么总是出现operator not applicable to this operand type这样的信息啊?郁闷啊?不知道怎么修改?请各位大侠帮帮小第吧
解决方案 »
- 请问能用ODAC编写一个类似SQLPLUS的工具吗,SQLPLUS的功能是如何实现的?
- 求几个高效控件,大数据量信息系统使用
- 用graphedt怎样编辑一个录制MP3的Graph?
- 在线等待...用delphi以最快速度写数据到MSSQLSERVER200里(实际就是把一个MSSQL服务器里的大量数据传到另一台MSSQL上,服务器上,要求自动
- 这个问题好奇怪,
- 我用IDFTP组件连接FTP服务器失败后怎么才可以让他重试,和设定重试的时间。
- 如何获取文件类型?
- 關于"dbgrid.gdselected in state "中state 的理解
- CSDN怎样保存呀?在线等待。。。。
- 初学者提问:为什么应用无法关闭
- adoquyer1语句子
- 请教:inputquery中的怪现象!
date字段是日期型吗?
什么数据库?
如果是access则在时间前后加 # 如:#2005-01-04#
query1.open;->
query1.active:=true;再检查sql语句有无问题!
你需要的时间类型的数据
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'select * from abc where date between '''+combobox1.text+''' and '''+combobox2.text+'''''select * from abc where date between #'+combobox1.text+'# and #'+combobox2.text+'#'
还有如果query1.sql.add('select *from abc where date between '''+combobox1.text+''' and '''+combobox2.text+'''');
改为query1.sql.add('select * from abc where date between '''+trim(combobox1.text)+''' and '''+trim(combobox2.text)+'''');
试试
with query1 do
begin
close;
sql.clear;
sql.add('select * from abc where datebetween '''+combobox1.text+
''' and '''+combobox2.text+'''');
open;
end;
execSQL是不返回值的,应该去掉
begin
query1.close;
query1.sql.clear;
//*from 改成* from
query1.sql.add('select * from abc where date between '''+combobox1.text+''' and '''+combobox2.text+'''');//用strtodatetime(combobox1.text)
query1.execsql;//一下两句只要一句
query1.open;
end;
我的思想是想通过6个COMBOBOX来选择年月日,根据起始的年月日和终止的年月日来查询库存的
而date是datetime类型的,不用转换可以吗???
可以将Combobox1的值转化成类型后赋给变量date1,将Combobox2的值转换成日期类型后赋给Date2
再用sql语句的between来实现区间查询!
为什么用6个COMBOBOX选择年月日,用DateTimePicker不好吗?query1.close;
query1.sql.clear;
query1.sql.add('select * from abc where date >= '''+FormatDateTime('mm/dd/yyyy',DateTimePicker1.Date)+''' and <='''+FormatDateTime('mm/dd/yyyy',DateTimePicker2.Date)+'''');
query1.execsql;
query1.open;
强烈建议你用datetimepicker控件
query1.sql.clear;
query1.sql.add('select * from abc where FormatDateTimeConvert(nvarchar(10),date, 20)>=:P1 and Convert(nvarchar(10),date, 20)<=:P2');
Parameters.ParamByName('P1').Value := formatdatetime('yyyy-MM-dd',DateTimePicker1.Date);
Parameters.ParamByName('P2').Value := formatdatetime('yyyy-MM-dd',DateTimePicker2.Date);
query1.execsql;
query1.open;
不然有些时候找不出来
SELECT *
FROM code
where dt between #2004-11-1# and #2005-1-1#
还有这个地方
query1.execsql;
query1.open;
……
我只能说一句:I服了you!
http://community.csdn.net/Expert/topic/3508/3508537.xml?temp=5.419558E-02
query1.sql.clear;
query1.sql.add('select * from abc where FormatDateTimeConvert(nvarchar(10),date, 20)>=:P1 and Convert(nvarchar(10),date, 20)<=:P2');
Parameters.ParamByName('P1').Value := formatdatetime('yyyy-MM-dd',DateTimePicker1.Date);
Parameters.ParamByName('P2').Value := formatdatetime('yyyy-MM-dd',DateTimePicker2.Date);
===========================
query1.execsql;
query1.open; 这里需要这么多麽?
==================================