Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a 2 tables,using sub queries i am retrieving some fields from both tables.after that i want to store the data in dataset using dataadapter fill method.while filling here which Table name has to specify?
any one help me...
Posted

Multiple SELECT statements can be sent to the database server in a single request. The problem here is that the tables generated from the queries have automatic names Table and Table1. However, the generated table names can be mapped to names that should be used in the DataSet.

SqlDataAdapter adapter = new SqlDataAdapter(
    "SELECT * FROM Customers; SELECT * FROM Orders", connection);
adapter.TableMappings.Add("Table", "Customer");
adapter.TableMappings.Add("Table1", "Order");

adapter.Fill(ds);
 
Share this answer
 
You can specify any name. It's not mandatory to specify the same name as in database. So,
C#
myAdapter.Fill(myDataset, "AnyTableName");

Basically, this table name would help you in retrieving the values in your frontend.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900