SELECT *
FROM history_data
WHERE (riqi >= '2003-2-1 0:00:00') AND (riqi <= '2003-2-28 23:00:00')
当这个时间段中4000条纪录的时候
在delphi 中怎么就会出错误,在SQL执行的时候是可以查询在delphi中我是这样写着:
with ExportAdoQuery do
begin
SQL.Clear;
SQL.Add('select * from history_data');
SQL.add('where riqi>=:time1 and riqi<=:time2');
Parameters.ParamByName('time1').Value :=datetime1;
Parameters.ParamByName('time2').Value :=datetime2;
Open;
end;提示的错误是:
.....class EOleException with message 'Data provider or other service returned ad E_FAIL status'各位帮帮忙,帮忙顶一下
FROM history_data
WHERE (riqi >= '2003-2-1 0:00:00') AND (riqi <= '2003-2-28 23:00:00')
当这个时间段中4000条纪录的时候
在delphi 中怎么就会出错误,在SQL执行的时候是可以查询在delphi中我是这样写着:
with ExportAdoQuery do
begin
SQL.Clear;
SQL.Add('select * from history_data');
SQL.add('where riqi>=:time1 and riqi<=:time2');
Parameters.ParamByName('time1').Value :=datetime1;
Parameters.ParamByName('time2').Value :=datetime2;
Open;
end;提示的错误是:
.....class EOleException with message 'Data provider or other service returned ad E_FAIL status'各位帮帮忙,帮忙顶一下
解决方案 »
- 如何查询出成绩最好的5个人?
- 寻找在浦东工作的星村镇、黄沟乡、苗馆乡的老乡们,大家聊聊.....
- 求救
- 虽然我没做过什么正式的项目,但学编程也一年多了,总感觉差点什么东西,请问要做window编程,应该要掌握些什么????
- 谁知道涉及到滚动条的api函数,及消息等
- delphi中怎么样创建子窗体?我已有建好的父窗体。
- 还是一个简单的问题
- 请问如何把EXCEL宏转换成PAS语句,谢谢!
- aspobject 采用object context 时如何得到页面post的内容呢?
- 如何让Timage控件中绘制的动画不会闪烁??
- 为什么会出现应用程序初始化(0xc000007b)失败
- Image1上放一个Image2, 如何把重叠的图像复制到Image3里?请兄弟们赐教!
你改为直接拼SQL语句,不要用参数试试with ExportAdoQuery do
begin
SQL.Clear;
SQL.Add('select * from history_data where riqi >= '
+ QuotedStr(datetime1) + 'and riqi <= ' + QuotedStr(datetime2));
Open;
end;
少了一个空格with ExportAdoQuery do
begin
SQL.Clear;
SQL.Add('select * from history_data where riqi >= '
+ QuotedStr(datetime1) + 'and riqi <= ' + QuotedStr(datetime2));
Open;
end;
with ExportAdoQuery do
begin
SQL.Text := 'select * from history_data where riqi >= '
+ QuotedStr(Formatdatetime('yyyy-hh-mm HH:ss:MM',datetime1)) + 'and riqi <= ' + QuotedStr(Formatdatetime('yyyy-hh-mm HH:ss:MM',datetime2));
Open;
end;
问题是:
我数据量少的时候就不会出现错误
在这个时间段我查询1000多条数据就不会出现错误的
begin
SQL.Clear;
SQL.Add('select * from history_data');
SQL.add('where riqi>='+#39+':time1'+#39+' and riqi<='+#39+':time2'+#39);
Parameters.ParamByName('time1').Value :=datetimetostr(datetime1);
Parameters.ParamByName('time2').Value :=datetimetostr(datetime2);
Open;
end;
datetime1:=datetostr(datetimepicker1.Date)+' '+timetostr(datetimepicker3.time);
datetime2:=datetostr(datetimepicker2.Date)+' '+timetostr(datetimepicker4.time);那为什么我查询数据纪录在3千多都没有出现错误!
我个人认为应该不是与字段的多少有关,不过我的是数据库里的varchar型与string型匹配来查询.....
begin
SQL.Clear;
SQL.Add('select * from history_data');
SQL.add('where riqi>=+'''+time1+''' and riqi<='''+time2+''')';
Parameters.ParamByName('time1').Value :=datetime1;
Parameters.ParamByName('time2').Value :=datetime2;
Open;
end;时间加上分号就行了。
var
sqlStr:string;
....with ExportAdoQuery do
begin
Close;
SQL.Clear;
sqlStr:=' select * from history_data where riqi>=%S and riqi<=%S '
sqlStr:=Format(sqlStr,[datetime1,datetime2])
SQL.Add(SqlStr);
try
Open;
except
...
end;
end;