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

InfoPath alternatives for form designing SharePoint

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

Also, you can check my previous posts on

Caching in Asp.Net,

Bind grid view using data reader in asp.net

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”;

string strSQL = “SELECT * FROM EMPLOYEES”;

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:

da.Fill(ds);

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

ds.ReadXml(“C:\\Employees.xml”)


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 SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply