如何将ADOQUERY中查询的结果打印输出,或者说将一个库表中的记录如何打印出,我的代码有什么错误(50分)

L

lili365

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,x,y:integer;
str:string;
begin

x:=10;
y:=10;
str:='';
with printerdo

begin

begin
doc;
for j:=0 to adoquery2.RecordCount-1do

begin

for i:=0 to adoquery2.FieldCount-1do

begin

str:=str+adoquery2.Fields.asstring;
end;

canvas.TextOut(x,y,str);
adoquery2.Next;
end;

enddoc;
end;

end;


这段代码不能将我的记录正常打印,请大侠们指正
 
你的str在不断的增加?
是否应该在更换记录的时候清空。
 
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,x,y:integer;
str:string;
begin

x:=10;
y:=10;
with printerdo

begin

begin
doc;
for j:=0 to adoquery2.RecordCount-1do

begin

str:='';
for i:=0 to adoquery2.FieldCount-1do

begin

str:=str+adoquery2.Fields.asstring+' ';
end;

canvas.TextOut(x,y,str);
y:=y+10;
adoquery2.Next;
end;

enddoc;
end;

end;

 
二位仁兄的方法都不正确,另有高招?!
 
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,x,y:integer;
str:string;
begin

x:=10;
y:=10;
str:='';
with printerdo

begin

begin
doc;
for j:=0 to adoquery2.RecordCount-1do

begin

for i:=0 to adoquery2.FieldCount-1do

begin

str:=str+adoquery2.Fields.asstring;
end;

canvas.TextOut(x,y,str);
str:='';
y:=y+10;
adoquery2.Next;
end;

enddoc;
end;

end;

上面这段代码打印出来的结果始终是最后一条记录,为什么,请指招
 
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,x,y:integer;
str:string;
begin

x:=10;
y:=10;
str:='';
with printerdo

begin

begin
doc;
adoquery2.First ;
for j:=0 to adoquery2.RecordCount-1do

begin

for i:=0 to adoquery2.FieldCount-1do

begin

str:=str+adoquery2.Fields.asstring;
end;

canvas.TextOut(x,y,str);
str:='';
y:=y+10;
adoquery2.Next;
end;

enddoc;
end;

end;

添加这一句adoquery2.First ;看一看
 
我已经试过了,仍然不可以
 
这里的高手都到那去了
 
得用别的对象吧!QuickRep
看看他里面的源代码就知道了。。
 
难道用这种方式就不能打印吗?
 
我看是x,y的问题
x,y都要变的,10太少了,至少要加100
y := y +100;
 
多人接受答案了。
 
顶部