C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
1
Reply
Can we load multiple tables in a Dataset? How?
Arun Singh
13y
7.5k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
Yes!We can load multiple tables in a dataset. This is the main advantage of using a dataset. DataSet dSet=new DataSet(); SqlConnection connection=new SqlConnection("your connection string"); SqlDataAdapter adapter=new SqlDataAdapter("select * from table1",connnection); adapter.Fill(dSet.Tables.Add()); adapter=new SqlDataAdapter("select * from table2",connnection); adapter.Fill(dSet.Tables.Add()); After adding the tables to a dataset, the following code describes how to make use of the dataset tables. If you want to make use of the first table in a dataset or if you want to copy that table data into a datatable,write as follows DataTable dt=new DataTable() dt=dSet.Tables[0]; The above code used to add tables in a dataset as much required.This scenario ensures the connectionless data access. Since the dataset is filled with many tables there is no need to have a database connection for every time we want to query the data and it also ensures the reusability of data.
Vinoth Srinivasan
12y
0
What are the steps to be followed to fill a dataset?
Explain how to enable and disable connection pooling in .NET?
Message