views:

22

answers:

1

Hi all,

I am executing a storeproc in asynchronous mode from codebehind using sqlcommands BeginExecuteNonQuery or BeginExecuteReader method . The storeproc returns multiple table as there are more than 1 Select statement.

I want to get those tables in a DataSet.

Is it possible?

Please help.

Thanks.

A: 

Use a SqlDataAdapter to fill the dataset like this:

SqlConnection conn = new SqlConnection(connection);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("exec spSomeStoredProc", conn);
adapter.Fill(dataset);

// dataset.Tables[0] - refers to resultset obtained from first SQL query 
// in stored procedure. dataset.Tables[1] - refers to resultset obtained
// from second SQL query. Etc. 

If it has to be done Async take a look at the code in the following article which shows how to pull back a DataSet asynchronously.

Asynchronous DataSet

Jonathan Kehayias

related questions