help with adding new columns to a new datatable
Hi folks--
I need to build a datatable and add values to it. I do now know how to Add Columns to the datatable once its created. What activity and syntax is available to add columns and data to a datatable?
J
-
Hi Jeff,
This is a quick little WF demo on how you can use the Geocortex Workflow Designer to manipulate datatables.
Cheers,
Kevin
<Activity mc:Ignorable="sap sads" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="326,1218" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:eac="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client" xmlns:eacg="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client" xmlns:eact="clr-namespace:ESRI.ArcGIS.Client.Tasks;assembly=ESRI.ArcGIS.Client" xmlns:gce="clr-namespace:Geocortex.Core.Extensions;assembly=Geocortex.Core" xmlns:gfc="clr-namespace:Geocortex.Forms.Client;assembly=Geocortex.EssentialsWpfApi" xmlns:gfci="clr-namespace:Geocortex.Forms.Client.Items;assembly=Geocortex.EssentialsWpfApi" xmlns:gr="clr-namespace:Geocortex.Reporting;assembly=Geocortex.Reporting" xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow" xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=System.Core" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=mscorlib" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:sxs="clr-namespace:System.Xml.Serialization;assembly=System.Xml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Sequence DisplayName="DataTable Stuff" sap:VirtualizedContainerService.HintSize="286,1138" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"> <Sequence.Variables> <Variable x:TypeArguments="x:String" Name="display" /> </Sequence.Variables> <sap:WorkflowViewStateService.ViewState> <scg:Dictionary x:TypeArguments="x:String, x:Object"> <x:Boolean x:Key="IsExpanded">True</x:Boolean> </scg:Dictionary> </sap:WorkflowViewStateService.ViewState> <Sequence DisplayName="Keep datatables consealed" sap:VirtualizedContainerService.HintSize="264,888"> <Sequence.Variables> <Variable x:TypeArguments="sd:DataTable" Default="[new datatable("test")]" Name="dt" /> </Sequence.Variables> <sap:WorkflowViewStateService.ViewState> <scg:Dictionary x:TypeArguments="x:String, x:Object"> <x:Boolean x:Key="IsExpanded">True</x:Boolean> </scg:Dictionary> </sap:WorkflowViewStateService.ViewState> <InvokeMethod DisplayName="Add Column 1" sap:VirtualizedContainerService.HintSize="242,128" MethodName="Add"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="sd:DataColumnCollection">[dt.Columns]</InArgument> </InvokeMethod.TargetObject> <InArgument x:TypeArguments="x:String">ColumnName1</InArgument> </InvokeMethod> <InvokeMethod DisplayName="Add Column 2" sap:VirtualizedContainerService.HintSize="242,128" MethodName="Add"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="sd:DataColumnCollection">[dt.Columns]</InArgument> </InvokeMethod.TargetObject> <InArgument x:TypeArguments="x:String">ColumnName2</InArgument> </InvokeMethod> <InvokeMethod DisplayName="Add Row" sap:VirtualizedContainerService.HintSize="242,128" MethodName="Add"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="sd:DataRowCollection">[dt.Rows]</InArgument> </InvokeMethod.TargetObject> </InvokeMethod> <Assign DisplayName="Add Data to row (0) col(0)" sap:VirtualizedContainerService.HintSize="242,60"> <Assign.To> <OutArgument x:TypeArguments="x:Object">[dt.Rows(0).Item("ColumnName1")]</OutArgument> </Assign.To> <Assign.Value> <InArgument x:TypeArguments="x:Object">["Programming"]</InArgument> </Assign.Value> </Assign> <Assign DisplayName="Add Data to row (0) col(1)" sap:VirtualizedContainerService.HintSize="242,60"> <Assign.To> <OutArgument x:TypeArguments="x:Object">[dt.Rows(0).Item("ColumnName2")]</OutArgument> </Assign.To> <Assign.Value> <InArgument x:TypeArguments="x:Object">["DataTables"]</InArgument> </Assign.Value> </Assign> <Assign sap:VirtualizedContainerService.HintSize="242,60"> <Assign.To> <OutArgument x:TypeArguments="x:String">[display]</OutArgument> </Assign.To> <Assign.Value> <InArgument x:TypeArguments="x:String">[dt.Rows(0).Item("ColumnName1").ToString() + " " + dt.Rows(0).Item(1).ToString()]</InArgument> </Assign.Value> </Assign> </Sequence> <gwa1:Alert sap:VirtualizedContainerService.HintSize="264,86" Text="[display]" Title="DataTable Data" /> </Sequence> </Activity>0 -
Kevin,
Thank you. This is helpful.
Is there a quick way to add the same data value for a column for all rows or will I have to somehow cursor through all the records to assign the data? I want to: dt.Rows(calculate all of them).Item("City") = "Greenville" - but don't know how to calculate all of them at once. (and I am lost as to the syntax for cursoring through if that is what I need to do).
For example, we are using a workflow to create an excel table for a mailing list from Addresses chosen by the user. The workflow writes the results from the query to a data table which is then converted to .xls (I used one of the samples). Our address points only have the full street address (ie. 35 N Main St) and a zipcode but no City or State because for our addresses, it is all Greenville, SC so it isn't included in the database.
However, for a mailing list that may get sent to a bulk mailing center, we need to add a column for City and State and just make them all Greenville and SC for all records.
Any help would be appreciated.
Thanks,
Carmen
0 -
I actually just found this that is helpful in understanding how to cursor through the table, if that is the only route.
But, I still would like to know if someone knows of a way to just "calculate all records to "Value X" for Column Y" with one assignment.
Thanks,
Carmen
0 -
Hi Carmen, were you able to figure this out? 0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
4 Kommentare