Best practice ??

Hi,

Now that i am working with Servoy for a while, i have the following question :

In many cases i need to retreive column data from another table.

I can retreive this data by either using a query or by using a foundset.
And of course there is the way of using relations, but i like to know the difference between the query and the foundset method

By foundset i mean :

//create foundset 
 var _vSet = databaseManager.getFoundSet(forms.bvko_navVerkooporderkaartenPrimStatusdetail_sub.controller.getServerName(),'bedrijven'); 
 //load record by ID
 _vSet.loadRecords(databaseManager.convertToDataSet(bedr_bedr_id));
 //retreive record
 var _vRecord = _vSet.getRecord(1); 
 verkok_kl_naam = _vRecord.bedr_naam

by query I mean :

var query = 'select bedr_naam from bedrijven where bedr_bedr_id= ?';
var args = new Array();
args[0] = bedr_bedr_id;
var dataset = databaseManager.getDataSetByQuery(forms.bcrm_navAfdelingenPrim_dtl.controller.getServerName(), query, args, -1);
verkok_kl_naam = dataset.getValue(1,1);

What is the best way to do this ( from a programming - and/or a performance point of view)

Regards,

Both require a query so I don’t think that there is (much) difference in performance.

The main difference is that your query, made into a dataset, gives you static information. The connection between the data and the database is not maintained (changes can not be pushed back).

A foundset however, always maintains the connection between the data and the database.

So, I guess the use of either of them depends on what you want to achieve.