Add Rows and Columns To Simple Data Connector during Runtime

Class library usage, coding and language questions.
Posts: 3
Joined: Thu Oct 20, 2016 7:57 pm

Add Rows and Columns To Simple Data Connector during Runtime

Post by twadhwa » Thu Oct 20, 2016 8:16 pm

I have to add unknown number of columns and unknown number of rows to the simple data connector. The column names and row data will be fetched at runtime and i want to store these for further use in the data source.

I have the below code. It works to a point that either i have columns or rows. I add the columns and can retrieve their names and index and count, etc. But as soon as i add a row the col count goes to zero and then i can only retrieve the row data.

int Col_Count = RepoTCode.SAP_GUI.S_PH0_48000510_InfoSetQuery.Tbl_SAP_Query_MMDDYYYY.Columns.Count;
for(int j = 0; j<=Col_Count-1; j++)
var OutputConn1 = DataSources.Get("Output_S_PH0_48000510_InfoSetQuery");
string Col_Name = RepoTCode.SAP_GUI.S_PH0_48000510_InfoSetQuery.Tbl_SAP_Query_MMDDYYYY.Columns[j].Text;
if(Col_Name.Trim().ToLower() == "job")
if(RepoTCode.SAP_GUI.S_PH0_48000510_InfoSetQuery.Tbl_SAP_Query_MMDDYYYY.Rows[0].Cells[j].Text.ToString().Substring(0,1) == "0")
Col_Name = Col_Name + "_ID";
Col_Name = Col_Name + "_Description";
Ranorex.Core.Data.Column col = new Ranorex.Core.Data.Column(Col_Name);

for(int x = 0; x<=3; x++)
var OutputConn = DataSources.Get("Output_S_PH0_48000510_InfoSetQuery");
string[] RowData = new string[Col_Count];

for(int z = 0; z<=Col_Count-1; z++)
RowData[z] = RepoTCode.SAP_GUI.S_PH0_48000510_InfoSetQuery.Tbl_SAP_Query_MMDDYYYY.Rows[x].Cells[z].Text.ToString();

Ranorex.Core.Data.Row row = new Ranorex.Core.Data.Row(RowData);

So here's is the end goal for this table
Capture.PNG (37.92 KiB) Viewed 867 times
I want to copy this whole table to data source and then be able to perform operations like

int z = Dataconn.Columns.IndexOf("PERSONID");
string CellValue = Dataconn.Rows[1].Values[z];

** Dataconn is the connector name

User avatar
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Add Rows and Columns To Simple Data Connector during Runtime

Post by odklizec » Fri Oct 21, 2016 12:16 pm


Please post a Ranorex snapshot (not screenshot) of the problematic elements. Snapshot is a critical piece of information to find best approach how to solve your problem. Thanks.

As for manipulating tables in code, please check the available samples here: ... mples.html
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration