How can we load multiple tables in to Dataset?

Showing Answers 1 - 23 of 23 Answers

PratIndia

  • 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>);

dap.Fill(ds,"<TableName>");

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

dap1.Fill(ds,"<TableName1>");

  Was this answer useful?  Yes

CAR

  • Sep 28th, 2006
 

By using data relation object we can load multiple tables

nraj71

  • Dec 11th, 2006
 

Write the select queries required in fill statement.

e.g.

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
 

Hi,

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,


Ans:

By Using SqlAdataAdapter Fill Method

DataSet ds=new DataSet();

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

dap.Fill(ds,"TableOne");

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

dap1.Fill(ds,"tableTwo");

karthik

  • Jun 9th, 2007
 

by using the data view method we can do it

  Was this answer useful?  Yes

Varung5

  • 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

TheDentist

  • 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