Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2006, 03:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Loading Lots of Data

Hello,

I'm loading a lot of data into the API; is there a way I can make that asyncronous, so I don't have to wait in the application the whole time while it loads? I know of the background worker control, but I'm in the API and not doing this in a windows form. What approach should I use? I'm using SQL Server express database.

Thanks.

Brian
__________________
Brian
 
Old January 28th, 2008, 12:57 PM
Authorized User
 
Join Date: Dec 2004
Location: Swindon, Wilts, United Kingdom.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

You can you BeginExecuteReader and then EndExecuteReader to do the query.

Code:
SqlConnection sqlConn = new SqlConnection( ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString );

using(SqlCommand comm = new SqlCommand())
{
     comm.CommandType = CommandType.Text;
     comm.CommandText = "Select * from tblBig";

     IAsyncResult res = comm.BeginExecuteReader();

     /////// Do your long operation

     SqlDataReader dr = comm.EndExecuteReader(res);

     //Enquire data.
}
Hope this helps,

Dominic




Similar Threads
Thread Thread Starter Forum Replies Last Post
New to ASP.NET and lots of problems Lessa ASP.NET 1.0 and 1.1 Basics 7 April 29th, 2008 07:05 AM
Loading Entity /w No Data pinch BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 20th, 2008 02:27 AM
Loading data from SQL levinll Pro VB Databases 0 January 25th, 2007 04:09 PM
Lots of errors and no solutions.... i8226girl BOOK: Beginning Access VBA 3 September 20th, 2005 05:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.