Column Name in getDatasetByQuery result?

Hi Folks

I’m using getDataSetByQuery and I can get the value of a row/column from its index. I want to select the value using the column name, though I may not know the position of that column in the index.

Is there a syntax I can use to do ‘dataset.getValue(myColumnName)’ ?

Appreciate feedback.

You can use:

dataset.myColumnName

for example with a loop:

	var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(),"SELECT myColumnName FROM myTable",null,-1);

	for (var i = 1; i <= dataset.getMaxRowIndex(); i++) {
		dataset.rowIndex = i;
		application.output(dataset.myColumnName);
	}

Joas:
You can use:

dataset.myColumnName

for example with a loop:

	var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(),"SELECT myColumnName FROM myTable",null,-1);
for (var i = 1; i <= dataset.getMaxRowIndex(); i++) {
	dataset.rowIndex = i;
	application.output(dataset.myColumnName);
}

Thanks Joas, so to get the value its just dataset.myColumnName.getValue() ??

Kahuna:
Thanks Joas, so to get the value its just dataset.myColumnName.getValue() ??

No, without the .getValue, just dataset.myColumnName:

var x = dataset.myColumnName;

Joas:

Kahuna:
Thanks Joas, so to get the value its just dataset.myColumnName.getValue() ??

No, without the .getValue, just dataset.myColumnName:

var x = dataset.myColumnName;

Great thanks Bud

Joas:

Kahuna:
Thanks Joas, so to get the value its just dataset.myColumnName.getValue() ??

No, without the .getValue, just dataset.myColumnName:

var x = dataset.myColumnName;

Joas - on testing that syntax returns a null value - where using the getValue(1,2) returns the correct value (integer)?

vweight = dataset.getValue(1,2); Correct.

application.output(‘Dataset by Column Name :’ + dataset.cui_itconf_pipe_horz_45); Returns Null.

Am I missing something?

Did you set the rowindex to 1?

Can you post your script?

Joas:
Did you set the rowindex to 1?

Thats what I missed Joas - works a treat now - thanks again.