.NET DataTable Search
-
I need to be able to search a DataTable for a non-primary key field. I'd assume the best way is just to populate a dataset and fill the table. But how do I search the table for non-primary key values? Nathan Lindley .NET Aficionado
Something along the lines of
for each datarow in datatable if datarow.coumn(i) = searchvalue then return what you want end if next
Mike Lasseter
-
Something along the lines of
for each datarow in datatable if datarow.coumn(i) = searchvalue then return what you want end if next
Mike Lasseter
-
I need to be able to search a DataTable for a non-primary key field. I'd assume the best way is just to populate a dataset and fill the table. But how do I search the table for non-primary key values? Nathan Lindley .NET Aficionado
Dim dr() as DataRow dr = datatable.Select("FieldName = 'something'") dr will be an array of rows from the datatable that match the query.
-
Dim dr() as DataRow dr = datatable.Select("FieldName = 'something'") dr will be an array of rows from the datatable that match the query.
-
You can't assign a dataRow to an Array of datarows...i think the error says something like '1 dimensional array System.Data.DataRow cannot be converted to System.Data.DataRow' ... thanks for the response though. :-D Nathan Lindley .NET Aficionado
It works. I've used it many times. You must declare the DataRow variable as an array. **use the parentheses after the name of the variable** Dim dr() As DataRow The select function of the DataTable class will return an array of data row objects. I am using .NET 2005
-
It works. I've used it many times. You must declare the DataRow variable as an array. **use the parentheses after the name of the variable** Dim dr() As DataRow The select function of the DataTable class will return an array of data row objects. I am using .NET 2005