Passing a Datatable name as a variable

Hi,

I have a set of 8 client related tables which includes a Master Client file that contains key fields like Branch, Adviser that needs to be added to each of the remaining Datatables. I have a process that uses the Client ID to locate the current record and then update data fields. Each of the related tables have the same fields to update and I was aiming to create a For Each process which would replace the Datatable name based on a String variable as follows:

  1. Load all Client Datatables
  2. Load Datable containing a list of the Datatables created in Step 1.
  3. For Each row in Datatable (using list in Step 2).
  4. Get Datable name as String from Step 3.
  5. Use that string variable as the Datatable name to do the updates of data.

The process works fine when I am specifiying the actual Datatable name, but I would need to replicate the same process multiple times replacing the Datatable name. I wanted to create 1 loop that would cycle through the list of Datatables and just replace throughout the process.

When I use the string variable as the Datatable name it doesn’t like it as says "Value of type ‘String’ cannot be converted to ‘DataTable’.

Is there a way that I can pass a string variable and it will find that as the datatable name?

Thanks

HI,

I think it may be better to use Dictionary if I understand your requirement correctly. Can you share your current workflow?

Regards,

Everything in this sequence is repeated and the only thing that needs to change in the Data Table name. dtAdviceOngoing is an actual Datatable, however I want to put this in a loop and simply replace the Datatable name each time.

Hi,

Probably the following mock sample will help you.

Sample
Sequence1.xaml (10.4 KB)

Regards,

1 Like