#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    2
    Rep Power
    0

    How to get multi-dataset with TADOQuery


    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=0

    while (1=1)
    begin
    Fetch Next
    from CustCursor
    into @Superior,@CountNum
    print @Superior
    print @countNum
    if(@@FETCH_STATUS <>0)
    begin
    break;
    end
    select * From [stuff]
    where superior=@Superior
    Set @count=@count+1
    end
    close custcursor
    deallocate custcursor

    above is the SQL statement,and How to get multi-dataset use
    TADOQuery,please!Thanks!

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    TAdoQuery has a NextRecordSet method that allows you to move from one recordset to the next. See the help documentation for TAdoQuery.NextRecordSet for more details. Hope this helps
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    2
    Rep Power
    0

    I know the TADOQuery's NextRecordSet


    I know the TADOQuery's NextRecordSet,but I can't use it correctly
    Could you give me some code !
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    Drop an ADODataSet component on the form and then do this to move to the next record set:
    Code:
    	while true do
    	begin
    		ADODataSet1.Recordset := ADOQuery1.NextRecordset;
    		if ADODataSet1.IsEmpty then
    			Break;
    		while not ADODataSet1.Eof do
    		begin
    		 // Move thru the record set.
    		 ADODataSet1.Next;
    		end;
    	end;
    Note that I typed that code off the top of my head, so you may need to make some minor adjustments. Hope this helps
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo