Thread: Listing 12-13
View Single Post
  #8 (permalink)  
Old August 16th, 2006, 09:17 AM
owen_is owen_is is offline
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem is that the Command.BeginExecuteReader call lets us continue dow n the page. The DB is not getting enough time to respond before the page finishes loading. The DataBind code in the callback function is therefore called AFTER the page has finished loading. Ahhh threads...

First chagne the SqlAsyncResult to IAsyncResult as mentioned above. Then when you get a blank screen of results do this...:

directly below the code of:
        // starting the aynchronous process with a callback
        ASyncResult = Command.BeginExecuteReader(CBMethod, Command);

Add the following:
        System.Threading.Thread.Sleep(100);
        DBCon.Close();

That should be enough to let the DB respond to our query so we can databind before page finished loading.