chen
(zijuan)
February 12, 2018, 9:54am
1
dataBase.Select .CopyToDataTable().DefaultView.ToTable(False, “Asset IP Address”,“Asset Names”,“Asset OS Name”)
i have many questions about 1)database.select and 2)the method DefaultView ,i searched in vb.net ,but can’t understand.
can anyone provide some examples.Thank you great!
Hi @chen ,
To understand about Database.select,refer the below link.
Hey @chen
Datatable Select:
DataTable has a Select method.It Gets an array of all DataRow objects that match the filter criteria, in the specified sort order.
Parameters
filterExpression
Type: - System.String
The criteria to use to filter the rows. For examples on how to filter rows, see DataView RowFilter Syntax [C#].
sort
Type: - System.String
A string specifying the column and sort direction.
Datatable Default View: -
Gets a customized view of the table that may include a filtered view, or a cursor position.
The DefaultView has the advantage of being there already by default, as the name implies.
The DefaultView property returns a DataView you can use to sort, filter, and search a DataTable.
Just clarifying things in a more clear way so it will be easy for Beginner level users
dataTable.DefaultView.ToTable(true, “Column1”)
or
DataView view = new DataView(table);
DataTable distinct_Values = view.ToTable(true, “Column1”, “Column2” …);
Where:
First parameter in ToTable() is a boolean which indicates whether you want distinct rows or not.
Second parameter in the ToTable() is the column name based on which we have to select distinct rows.
Only these colu…
Regards,!!
Aksh
1 Like