My bad. When I look at your post a bit closer, I now see that the stored procedure completely recreates the entire #temp table each time it is called. For some reason I thought you were creating the #temp table once then having the stored procedure page through it.
I didn't realize that the whole query was being executed for each page - I looked at it too quickly.
My comment about connection state was based on the faulty assumption that the #temp table was created once and then reused repeatedly, and that would not work in a web situation.
Sorry for misunderstanding.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com