In this article we will discuss about what is a dataadapter in asp.net and how to use dataadapter in asp.net. Also you can check out my previous posts on: Adding meta tags to aspx pages in asp.net, Bind gridview using datareader in asp.net and Method Overloading in C#.Net.
DataAdapter will act as a mediator between dataset and database server. This will perform 2 things:
– It will read data from database and place within dataset in the form of datatables.
– The manipulation on the dataset table will be updated with 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();
Here Employees is the datatable name.
Check out the below diagram how it is working: