dtMasterTable.Select(“[Column0] = '”+var1+“’ AND Convert([Column4],System.String.Trim) = '”+var2+“'”)
Var1 & Var2 are variables.
Column4 has some spacing in the front and at the end, so need to trim and compare the values.
Thanks in advance!
dtMasterTable.Select(“[Column0] = '”+var1+“’ AND Convert([Column4],System.String.Trim) = '”+var2+“'”)
Var1 & Var2 are variables.
Column4 has some spacing in the front and at the end, so need to trim and compare the values.
Thanks in advance!
Hi @pk123
Please Try this one.
[Column4].ToString.Trim
Here you are converting Column4 To string then Applying Trim. Trim is String Operation
Thanks
I tired the below statements but it didn’t work.
dtMasterTable.Select(“[Column0] = '”+var1+“’ AND [Column4].ToString().Trim() = '”+var2+“'”)
dtMasterTable.Select(“[Column0] = '”+var1+“’ AND [Column4].ToString.Trim = '”+var2+“'”)
@pk123 can you show me what are you doing by this and what you want…please attach screenshot of excel file.
Here is the sample data:
Datatable 1
Column0 | Column1 | Column2 | Column3 | Column4 | Column5 | Column6 | Column7 | Column8 | Column9 |
---|---|---|---|---|---|---|---|---|---|
abc | value | value | value | value | 123 | value | value | value | '456789 |
xyz | value | value | value | value | 456 | value | value | value | '2223 |
zxc | value | value | value | value | 789 | value | value | value |
dtMasterTable
Emp ID | F Name | L Name | City | ID |
---|---|---|---|---|
123 | abc | qwe | CBE | '456789 |
456 | xyx | asd | BLR | '2223 |
We need to compare the ID Column and Emp ID. This ID column has spaces and it needs to be trimmed. I am iterating the first datatable. Var1 and var2 are variables and they have their values from datatable 1
can’t you try with AsEnumerable?
dt_MasterTable.AsEnumerable.Where(Function (r) r.item(“ID”).ToString.Trim = “value1” And r.Item(“Emp ID”).ToString.Trim = “value2”).CopyToDataTable()
Thanks @whitestar
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.