Hi @andrzej.kniola,
Just in case my previous reply confuse you.
With that syntax, I get the error: The expression contains undefined function call DT.Columns()
May I have your advice again ? Thanks so much.
Hi @andrzej.kniola,
Just in case my previous reply confuse you.
With that syntax, I get the error: The expression contains undefined function call DT.Columns()
May I have your advice again ? Thanks so much.
DT.Select(β[" & DT.Columns(0).ColumnName & "] = 'β & stringVariable &"β").CopyToDatatable
or in a more readable way:
string filterTemplate = "[{0}] = '{1}'"
string filter = String.Format(filterTemplate, DT.Columns(0).ColumnName, stringVariable)
DT = DT.Select(filter).CopyToDatatable
2nd option makes it also much easier to understand and/or modify as needed (and is very similar to what was in the Academy if I remember correctly).
Thanks, let me try.
I have just passed only the basic oneβ¦
Just a quick response to your option 1:
I typed: DT1.Select(β[β& DT1.Columns(1).ColumnName & β] = 'β & StringA &β'β).CopyToDatatable
but get an error: Assign : Cannot perform β=β operation on System.Double and System.String.
For Option 2, would you mind telling me what does β[{0}] = β{1}ββ mean in the filterTemplate ?
Hi @andrzej.kniola,
My bad, I think your option 1 should work, it is the problem of my excel file. I think I just need to change the values to string in my excel.
Hi @andrzej.kniola ,
Just would like to share, after your advice plus some trials, that the datatable takes column0 as the column name for column index = 0, and column1 as the column index = 1, etc. The following works for me also:
DT1.Select(β[Column0] = 'β & StringA &β'β).CopyToDatatable
@indra I think it will work only in excel application scope but Iβm using data scrapping and taking that in datatable. for that datatable I want to check whether my requirement is contains r not by using select function
cdr.Select(βClient=β+βββ+serverName+βββ).CopyToDataTable
@aksh1yadav Hi i have tried your way, apparently mine gives me error. Could you help me with my lines