How to populate dataset with data adapter and XML in Asp.Net?

In this post, we will discuss how we can populate a dataset with data adapter in

Also, you can check my previous posts on

Caching in Asp.Net,

Bind grid view using data reader in

Asp.Net MVC4 Controller class example.

Populate from Data Adapter:

We can fill the dataset by calling the Fill() method of the Data Adapter class. Below is the full code that will fill the database.

string conn = “You connection string will goes here”;


SqlConnection conn = new SqlConnection(conn);

SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);

DataSet ds = new DataSet();

da.Fill(ds, “Employees”);

Also you can call the fill method like below:


But when you want to retrieve then you have to retrieve using the index like ds.Tables[0].

But in the above method you can retrieve like ds.Tables[“Employees”].

Populate from XML:

To load XML into a DataSet class, we have to call the ReadXML() method like below:

DataSet ds = new DataSet();


Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →