I am attempting to return all column values from an Sqlite db to a Qchart in qml in Ubuntu SDK - the db contains various fields including kilometres, miles, etc. I would like to return all values in one field (e.g. kilometres) into the Qchart - I know that this is possible using an array, e.g.
function testData(){
var kilometres = ["25","45","42","39"];
return kilometres;
}
this will happily display the values 25,45,42 & 39 in the chart. However, try as I might, I cannot find a way to pass the values contained in the database to the array shown above. The following is what I have tried so far:-
// Chart Data
function getData() {
var db = LocalStorage.openDatabaseSync("data.sql", "1.0", "mileageDataBase", 10000000);
var res = "";
db.transaction(
function(tx) {
var rs = tx.executeSql('SELECT kilometres FROM mpg');
res = rs.rows.item().kilometres;
}
);
return res;
}
(Please note that an earlier version of this question I asked about returning values to a TextField. I thought I could use this TextField to populate the graph but, after some experimentation, that does not appear to be the case. Apologies for the confusion.)