adoquery1.sql.Add('select top 6 id,title from jxoption');
之前要加一句:
adoquery1.sql.clear;
之前要加一句:
adoquery1.sql.clear;
解决方案 »
- 本地数据导入
- 新手:如何用多线程实现查询记录,没有等待感的效果?
- 功能实现了,请qxf32和zhangxiaommmm再领分,谢谢了
- 用delphi自带的TExcelApplication控件如何在工作表中插入一行?
- 加价,人民币500元求解一个完整的解决方案.......
- 能否将报表Preview的结果存为.bmp图片?
- Error creating form:Access violation at address 40003c4c in module 'vcl50.bpl'.Read of address 4874656c.
- DbGrid的DrawColumnCell事件问题
- 关于循环减库存的问题
- 各位高手,请告诉我DELPHI,C++BUILDER该选哪一个?
- 帮忙看看http://www.yuanzn.com/image/main.jpg上的工具栏用的是什么控件?
- ^_^ 大家来UP:开辟J++ Builder专栏,同意者有分?
adoquery1.active := false;
adoquery1.sql.cleare;
你试试。
for i:=1 to boardnum do
begin
scontent:=boards[i];
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.Add('select top 6 id,title from jxoption');
adoquery1.sql.add(' where boardname=:boardname order by id desc');
ADOQuery1.Parameters.ParamByName('boardname').Value:=scontent;
ADOQuery1.open;
end;
做个循环最后ADOQuery1数据集里存的是最后一个条件筛选的内容,即:
ADOQuery1.Parameters.ParamByName('boardname').Value:=boards[boardnum];
没有必要用循环吧?!
adoquery1.close;
adoquery1.sql.Add('select top 6 id,title from jxoption');
adoquery1.sql.add(' where boardname=:boardname order by id desc');
for i:=1 to boardnum do
begin
scontent:=boards[i];
ADOQuery1.Parameters.ParamByName('boardname').Value:=scontent;
ADOQuery1.open; while not adoquery1.eof do
begin
scontent:=format('%8s%50s',[adoquery1['id'],adoquery1['title']]);
tmp.Add(scontent);
adoquery1.next;
end;
adoquery1.close;
end;
adoquery1.close;
adoquery1.sql.clear;
……
adoquery1.open;
——你不看caoyq(草民呆瓜)
begin
scontent:=boards[i];
adoquery1.close;
adoquery1.sql.Add('select top 6 id,title from jxoption');
adoquery1.sql.add(' where boardname=:boardname order by id desc');
ADOQuery1.Parameters.ParamByName('boardname').Value:=scontent;
ADOQuery1.open; while not adoquery1.eof do
begin
scontent:=format('%8s%50s',[adoquery1['id'],adoquery1['title']]);
tmp.Add(scontent);
adoquery1.next;
end;
adoquery1.close;
end;
如果你要打开一串ADOQuery,那你也应该将ADOQuery声明成一个ADOQuery数组才行,且每次循环都给不同的ADOQuery。SQL赋值并打开啊。
begin
close;
for i:=1 to boardnum do
begin
with sql do
begin
clear;
add('select top 6 id,title from jxoption');
add(' where boardname=:boardname order by id desc');
end;
trou:=boards[i];
Parameters.ParamByName('boardname').Value:=trou;
if not prepared then
prepared;
try
open;
except
execsql;
end; while not eof do
begin
scontent:=format('%8s%50s',[ADOquery1['id'],ADOquery1['title']]);
tmp.Add(scontent);
next;
end;
end;
end;
这段代码我只是把query1改成了adoquery1,其他都没变,可是query1就行,真是搞怪了!