Hi! I have a problem. I need to select rows in a datatable. The condition to be selected is that 7 first characters of a specific column (string) are different from “GENERAL”. I would like to do it with a select command within an Assign box, but it does not work.
And how would I do it if instead of the condition being placed on the 7 first characters of the field, it would be place on wherever this combination, “GENERAL” might be within the field?
Thank you very much SShubham for your quick question.
The problem is that I need to extract the rows that match the condition to a datarow to delete them from the original datatable, and this solution seems to need to store the result into an array, isn’t it?
Thanks again. But, how do I do step 1 when I need to select rows extracting only a part of a string field in a column? When I tried to use your initial suggestion, I got an error, saying that I could not use a IEnumerable method to get a variable of type datarow.
My data table is “tablab”, the column I am interested in is “Name”, and the rows I need to delete are those which do not include the collection “GENERAL” within the field in column “Name”.
Note: Column “Name” cells are fields of variable lenght, so “GENERAL” may be a part of it.
Attached is the code for your reference. I have used filter activity to remove the rows of matching condition.
The output is saved in the same datatable.
Please check.
You an try below linq to get rows which so not contains “General”
(From r In dtInput Where Not r.Item(“Department”).ToString.ToUpper.Contains(“GENERAL”) Select dtOutput.LoadDataRow(New Object() { r.Field(of Object)(“Name”),r.Field(of Object)(“Department”) },False)).CopyToDataTable