I’d really appreciate any help with this one.
The process looks to gather information for on-boarding and its currently built up around a main datatable (dt_Master1) which contains a few other datatables; fname & sname, along with some other string columns such as joining date.
My issue is that i cannot seem to loop through the information gathered with a simple write line without getting an error:
The error received: For Each Row in Data Table: Unable to cast object of type ‘System.DBNull’ to type ‘System.Data.DataTable’.
Any help will be greatly appreciated. Thanks in advance
the error comes from the following:
the looped row column fname / sName is null, so it cannot convert
for inspections we would recomment to use the immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
for tracings / understandings
- loop over a test data datatable which is prepopulated in advance
for handling empty column values if it will occur or not
use within the for each row:
IF(isNothing(CurrentRowMaster("fname") orElse isDBNull(CurrentRowMaster("fname")), new DataTable(), Ctype(.....))
Hi, thanks for your quick reply.
I’m a bit confused as i’m looping through the test data provided in the screen shots… so i’m confused as to how the values could be null?
as mentioned above all can be verified, inspected when debugging and using the immediate panel. Here you can fire several statements for inspections
I’ve watched the video & i’m none the wiser.
I can see the datatables are populated - why are they coming up as null? Should i be using another method to read the data?
as mentioned use the immedediate panel e.g.
- set a breakpoint within the for each body e.g. write line activity
- debug and get paused
- immediate panel: CurrentRowMaster(“fName”)
[ ] is about empty tablename property value
I feel as though we’re talking at cross purposes here.
I have created a duplication of the work that’s in production. All the datatables have test data in them. I’m just trying to understand why the fName datatable is showing as Null. I can see that it’s null in the locals table & that it’s null in the original error message. What i’m trying to understand is why it is null and how I can go about accessing the nested rows, which should be present.
I have attached a copy of the project. Please help.
Nested DataTables.zip (3.2 KB)
pattyricarte / sharique.khan / Palaniyappan would either one of you be able to help please?
Kindly note from your shared Implementation:
As the Master will not have populated the fName, sName columns so the CType is failling. We mentioned above how to catch:
IF(isNothing(CurrentRowMaster("fname")) orElse isDBNull(CurrentRowMaster("fname")), dt_fName.Clone, Ctype(CurrentRowMaster("fname"), DataTable))
and for the exploration on how it will handled the populated column we can prototype:
So lets summarize:
- with a defensive null check we can handle empty column values
- When the data column is correct populated we can convert and use it for the loop
@Palaniyappan would you be able to offer some help here?
Can you tell me how i’d go about adding data to dtMaster1?
For example, i’d like to add a distinct ID and Joining date, but then multiple names to both dt_fname & dt_sname. When i try to copy the names from dt_fname & dt_sname in to dtMaster, all the names are added to one ID, rather than separate.
A standard Add DataRow Activity doesn’t seem to work - any ideas?
Thank you in advance