A DataView provides you with a dynamic view of a single set of data to which you can apply different sorting and filtering criteria, similar to the view provided by a database.
However, a DataView differs significantly from a database view in that the DataView cannot be treated as a table and cannot provide a view of joined tables.
You also cannot exclude columns that exist in the source table, nor can you append columns, such as computational columns, that do not exist in the source table.
C# Code for ASP.Net Convert DataSet to DataView
// SQL Select Command
SqlCommand mySqlSelect = new SqlCommand("select * from categories", mySQLconnection);
mySqlSelect.CommandType = CommandType.Text;
SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlSelect);
DataSet myDataSet = new DataSet();
mySqlAdapter.Fill(myDataSet);
// Convert DataSet to DataView using DefaultView property associated with DataTable stored inside the DataSet
DataView dView = myDataSet.Tables[0].DefaultView;
No comments:
Post a Comment