vb.net - Rowfilter Select syntax using a value stored in a variable -
i using vb.net , need utilize datatable.select row has matching value.
consider have datatable_a, has many rows. interested row/rows matches search criteria. in case, must row (rowa), has answera stored in column_a.
i know can utilize method below find answer:
rowa = datatable_a.select("column_a = 'answera'") however, value 'answera' stored in variable_a.
i have tried using
rowa = datatable_a.select("column_a = 'variable_a'") unfortunately, still not datarow, column_a = 'answer a'.
i have studied explanation in website dataview rowfilter syntax [c#], not find clue there.
thank you.
if want select subset of datatable rows using select method , variable contains value filter rows need write
dim variable_a = "mysearchcriteria" dim rowsselected = datatable_a.select("column_a = '" & variable_a & "'") this means want rows in column_a (a string column) contains value "mysearchcriteria" stored in variable_a. filter status created concatenating literal string describing name of column , operator content of variable_a. since column_a assumed string column need encapsulate variable_a between single quotes.
and remember select returns array of datarow match filter expression.
for each row in rowsselected console.writeline(row("column_a").tostring) next vb.net select datatable
No comments:
Post a Comment