How to get every row value from particular column of a table in c# automation script.
Hi Niraj,
It is possible to get all the values from a specific column using the classes available in the C# code blocks for automation scripts:
- First you will need to get all the keys from the table. For this purpose you will need to use GetTablePrimaryKeys (Element methods). This method will return the list of keys in a string array
- Next, using an iterator (e.g. a for loop or foreach) you will need to get the value from a specific column. For this purpose you could use either GetParameterByPrimaryKey or GetParameterDisplayByPrimaryKey (Element methods). The last method could be used for example when the column contains discreet values (it will return the displayed value)
Please find below an example:
ScriptDummy dummyElement = engine.GetDummy("dummyElement");
string[] saKeys = dummyElement.GetTablePrimaryKeys(/*TABLE_PID*/1000);
object[] oColumnValue= new object[saKeys.Length];
for(int i=0 ; i< saKeys.Length; i++)
{
oColumnValue[i] = dummyElement.GetParameterByPrimaryKey(/*COLUMN_PID*/1002, saKeys[i]);
}