How can we load multiple tables in to Dataset?

Showing Answers 1 - 9 of 9 Answers


  • Jul 12th, 2006

We can do this by using DataAdapter's fill Method.Syntax for This is

DataSet ds=new DataSet();

SqlDataAdapter dap=new SqlDataAdapter(<query1>,<connection>);


SqlDataAdapter dap1=new SqlDataAdapter(<query2>,<connection>);


  Was this answer useful?  Yes


  • Sep 28th, 2006

By using data relation object we can load multiple tables


  • Dec 11th, 2006

Write the select queries required in fill statement.


Adp.Fill("Select * from Table1;Select * from Table2;Select * from Table3",DS)

This statement wil generate Dataset with 3 datatables.

  Was this answer useful?  Yes

Mob: +91 9849255958

  • Jan 4th, 2007


Actually ....u have to write multiple select statements while creating a dataadapter , not in fill() method.

ex:   SqlDataadapter da = new SqlDataadapter("select statement1; select statement2; .....", connection);

  Was this answer useful?  Yes

Mob: +91 9849255958

  • Jan 4th, 2007

To create multiple datatables in a dataset , u have to write multiple select statements........

each select statement creats a datatable in dataset...u can write  ; (semicolon) seperated select statements in a command text or u can write as stored procedure ....

  Was this answer useful?  Yes

Hi All,


By Using SqlAdataAdapter Fill Method

DataSet ds=new DataSet();

SqlDataAdapter dap=new SqlDataAdapter(Select
* from <tablename>,<connection1>);


SqlDataAdapter dap1=new SqlDataAdapter(Select
* from <tablename>,<connection1>);



  • Jun 9th, 2007

by using the data view method we can do it

  Was this answer useful?  Yes


  • Jun 15th, 2010

You can pass multiple select statements in data adapter separated by “;”.SqlDataAdapter dataAdapter = new SqlDataAdapter(“select * from table1;select * from table2”, connection);DataSet ds = new DataSet();dataAdapter.Fill(ds);

  Was this answer useful?  Yes


  • Apr 23rd, 2013

I know the DataAdapter provides this functionality but I prefer to create a SQL Statement that performs the merge and creates a single DataSet. The servers are usually high powered machines so by letting it do the work, the performance would be better. If its a critical part of the code where performance is critical then I would create a stored procedure to execute the join and feed the results back to the client.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions