I wanted to share my experience where the project required with the use of datatables to store data intermediate without moving the data to the database and required to perform some operations. For ex: Selecting some specified rows and computing some arithmetic operations.
Datatable is an object in the ADO.NET Library. Generally, Dataset and Dataview uses the Datatable. Datatable helps in the sorting and Selecting the data present in it by using its methods.
Copying Data From SqlDataSource To DatatableThere is no way to perform direct copy from sqldatasource to datatable. Therefore, we use DataView to copy the data from sqldatasource to datatable.
DataView dv = (DataView)sqlDS1.Select(DataSourceSelectArguments.Empty); DataTable dt = DataTable(); dt = dv.ToTable();
Sorting Data in Datatable
DataTable.Select() is a method which helps in sorting the data. The select() has 4 overloads. According, to My project
The Works Clause in SQL. I.e,
DataTable dtr = dt; DataRow uniname = dtr.Select("Name Desc");
DataTable dtr = dt; DataRow uniname = dtr.Select("City=Bangalore");
Filtering Data in Datatable
DataTable dtr = dt; Object Sum = dtr.Compute("Sum(Salary)","date > 1/1/12 and date < 1/1/13 and ID=1 ");
Trainee software engineer In Canarys automation Pvt Ltd.