var i : integer; booklist1 : tbooklist; book1 : tbook; ss,ss1 : string; begin book1 := quy_test.GetBook; ss := 'select * from testtable where id in ('; booklist1 := dbgrid1.selectedrows; for i := 0 to booklist1.Count - 1 do begin quy_test.GotoBook(pointer(booklist1[i])); if i <> booklist1.Count - 1 then ss1 := ss1 + '''' + quy_test.fieldbyname('id').asstring + '''' + ',' else ss1 := ss1 + '''' + quy_test.fieldbyname('id').asstring + ''''; end; quy_test.GotoBook(book1); quy_test.FreeBook(book1); ss := ss + ss1 + ') '; quy_test.Close; quy_test.SQL.Clear; quy_test.SQL.Add(ss); frReport1.ShowReport; end;说明:quy_test连接dbgrid1
i : integer;
booklist1 : tbooklist;
book1 : tbook;
ss,ss1 : string;
begin
book1 := quy_test.GetBook; ss := 'select * from testtable where id in ('; booklist1 := dbgrid1.selectedrows;
for i := 0 to booklist1.Count - 1 do
begin
quy_test.GotoBook(pointer(booklist1[i]));
if i <> booklist1.Count - 1 then
ss1 := ss1 + '''' + quy_test.fieldbyname('id').asstring + '''' + ','
else
ss1 := ss1 + '''' + quy_test.fieldbyname('id').asstring + '''';
end;
quy_test.GotoBook(book1);
quy_test.FreeBook(book1);
ss := ss + ss1 + ') '; quy_test.Close;
quy_test.SQL.Clear;
quy_test.SQL.Add(ss);
frReport1.ShowReport;
end;说明:quy_test连接dbgrid1