Gabriel_T
(Gabriel Milenko Tomich Fernández de Castro)
1
Hello, I am working with the 1rst assignment of the advanced course from the academy. While trying to use the “DataTable.Select()” to filter the datatable I get the following error:
The assign has the following: System1_DataTableProcessed = System1_DataTable.Select("Type= W15 AND Status= Open ")
Im confused, at first i thought that the “.Select()” method gave a datatable as output, then after receiving the error the first time i tried changing the type of the variable to the right (the “System1_DataTableProcessed”) but even after that i cant make it work properly.
.Select() returns a 1-dimensional array. If you would like a data table, just add .CopyToDataTable on the end of it. There are times when you do want to use the filtered dataset as an array, though too.
Regards.
3 Likes
Gabriel_T
(Gabriel Milenko Tomich Fernández de Castro)
3
@ClaytonM Thank you very much! Sadly, now I have an issue when filtering because it doesn’t. The datatable after filtering looks like in the image and it contains rows with elements of “WI2” Type.
lol, hey can you tell me where you have it filtering the data table? I found where you are extracting the data table (I think), but I don’t see anywhere you are filtering it.
Gabriel_T
(Gabriel Milenko Tomich Fernández de Castro)
9
Sorry, I have it on the main flow, inside the init state machine
Looks like you did it correctly, although I was not able to run it.
I assume you tried both the Filter activity and the Assign.
You can also change your Assign to use this code instead which is usually the syntax I use: System1_DataTable.AsEnumerable.Where(Function(r) r("Type").ToString.Trim.ToUpper = "WI5" AND r("Status").ToString.Trim.ToUpper = "OPEN").CopyToDataTable
Gabriel_T
(Gabriel Milenko Tomich Fernández de Castro)
11
@ClaytonM thank you for your patience and tips, i tried with the code you provided and it didn’t work.After debbuging I received the following message:
I tried to clear the variables used as databases and when i reach the “Clear Datatable” activity it says the same. Is there a way to initialize the datatables, or is this even needed?
That errors tells me you are using a variable with no value in the activity “Assign”. Note: always rename your activities so you know the exact activity that failed.
I would verify that you have no empty values being used in the Assign activity that failed.
The DataTable gets initialized at the start of its scope, so you don’t need to clear it or anything. If you do need to initialize it in some cases, then you can also use an Assign with new System.Data.DataTable()
Gabriel_T
(Gabriel Milenko Tomich Fernández de Castro)
13
You are right! When running the main flow the variables that will hold datatables are initialized.
But, after executing the “System1_Extract_Data” flow this variables got “Null” as value. My error was not assigning the value of the extracted datatable to the argument invoked from the “System1_Extract_Data”
out_System1_DataTable = System1_DataTable
with out_System1_DataTable as the output argument and System1_DataTable as the value.
Its a very basic mistake and I’m a little embarrassed but I really appreciate your time and effort helping me, it worked!