declare @count int declare @Superior varchar(20) declare @countNum int declare CustCursor Cursor for select superior,count(superior) as RecordeCount from [stuff] group by Superior for read only open custcursor set @count=0while (1=1) begin Fetch Next from CustCursor into @Superior,@CountNum print @Superior print @countNum if(@@FETCH_STATUS <>0) begin print 'break' break; end select * From [stuff] where superior=@Superior Set @count=@count+1 end close custcursor deallocate custcursorGO 这是我的SQL语句我如何在TADOQuery中选择使用那个数据集
也就是说有没有人会用TADOQuery的 NextRecordSet方法, 这个方法有人会用吗
好象一个ADOQuery是不支持多个数据集. 用多个啦.
帮助里的 var TempDataSet: TCustomSQLDataSet; nRows: Integer; begin TempDataSet := SQLStoredProc1; // start with 1st record set while TempDataSet <> nil do begin TempDataSet.First; while not TempDataSet.Eof do begin // process each record TempDataSet.Next; end; if TempDataSet <> SQLStoredProc1 then // don’t free the original! TempDataSet.Free; TempDataSet := SQLStoredProc1.NextRecordSet; // get next set end; end;
不好意思,这是BDE的,不是ADO的,谢谢!
select * from a jion b
我现在将问题改为----------如何用TADOQuery的NextRecordSet
这个需要adoquery调用存储过程,在存处过程中返回多个数据集才能够使用,否则那来的多个数据集?The ADO Recordset object returned by NextRecordset must be assigned to the Recordset property of an ADO dataset component, such as TADODataSet, to be accessible.这个是delphi的帮助,我没有用过,但是我认为应该不困难。
一个sql命令本身就可以使用多个数据集呀。
declare @Superior varchar(20)
declare @countNum int
declare CustCursor Cursor for
select superior,count(superior) as RecordeCount
from [stuff]
group by Superior
for read only
open custcursor
set @count=0while (1=1)
begin
Fetch Next
from CustCursor
into @Superior,@CountNum
print @Superior
print @countNum
if(@@FETCH_STATUS <>0)
begin
print 'break'
break;
end
select * From [stuff]
where superior=@Superior
Set @count=@count+1
end
close custcursor
deallocate custcursorGO
这是我的SQL语句我如何在TADOQuery中选择使用那个数据集
这个方法有人会用吗
用多个啦.
var
TempDataSet: TCustomSQLDataSet;
nRows: Integer;
begin
TempDataSet := SQLStoredProc1; // start with 1st record set
while TempDataSet <> nil do
begin
TempDataSet.First;
while not TempDataSet.Eof do
begin
// process each record
TempDataSet.Next;
end;
if TempDataSet <> SQLStoredProc1 then // don’t free the original!
TempDataSet.Free; TempDataSet := SQLStoredProc1.NextRecordSet; // get next set
end;
end;