INTDT.AsEnumerable.Select(function(x) x(“CPR”).ToString).CopytoDatatable
The above LINQ gives the error
Main.xaml: BC30456: ‘CopytoDatatable’ is not a member of ‘EnumerableRowCollection(Of String)’.
INTDT.AsEnumerable.Select(function(x) x(“CPR”).ToString).CopytoDatatable
The above LINQ gives the error
Main.xaml: BC30456: ‘CopytoDatatable’ is not a member of ‘EnumerableRowCollection(Of String)’.
when selectin a column value only and not a datarow we cannot use CopyToDaTable as this method is expecting Datarows
we can do
arrValues | String List =
INTDT.AsEnumerable.Select(function(x) x(“CPR”).ToString).toList
and using the Collection to DataTable Activity
OR (we would suggest)
Assign Activity
dtResult =
INTDT.DefaultView.ToTable(false, {"CPR"})
My original requirement was to create a datatable from existing one with 2 columns so that the second column has value only before space in the text.
Is there a way to achieve it directly without creating the list
please share some input samples along with expected output. So we can check the solution options we do have
slno ID
1 MH 345
2 MH 6544
3 MH 877
We need to get ouput datatable as follows
slno ID
1 345
2 6544
3 877
Output is whatever that comes after space in second column
→ Input-> Build DataTable
Output= InputDataTable
→ Use below syntax in Assign activity:
OutputDataTable= (From row In InputDataTable.AsEnumerable()
Select InputDataTable.Clone().Rows.Add(row.Field(Of String)("slno"), row.Field(Of String)("ID").Split(" "c)(1))
).CopyToDataTable()
OutputDataTable is of DataType System.Data.DataTable()
Output:
Regards
A few things are unclear
Lets assume the following
input:
slno | ID |
---|---|
1 | MH 345 |
2 | MH 6544 |
3 | MH 877 |
Expected output:
slno | ID |
---|---|
1 | 345 |
2 | 6544 |
3 | 877 |
Options:
How to Update Data Column Values of a Data Table | Community Blog
When LINQ is needed (DataTable Reconstruction approach)
Assign Activity:
dtNew = dtOrig.Clone
Assign Activity:
(From d in dtOrig.AsEnumerable
Let cs = d(1).toString.Trim.Split(" "c).Last()
Let ra = new Object(){d(0),cs}
Select r = dtNew.Rows.Add(ra)).CopyToDataTable
feel free to adapt on trim, colName Access…
Got the solutions. Thanks a lot guys.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.