Hi guys,
I created a separate .js file with a database pseudo class for handling SQLite database operations.
I included this file into my main .js file with the statement:
document.write('<script type="text/javascript" src="DB.js"></script>');
Works fine.
Now I want to write a function that gets a string from an SQL SELECT statement without adressing each field name in the function.
That is because I want to use this function no matter how the SELECT statement looks like.
The DroidScript sample code looks like this:
//Callback to show query results in debug.
function OnResult( results )
{
var s = "";
var len = results.rows.length;
for(var i = 0; i < len; i++ )
{
var item = results.rows.item(i)
s +=
item.id + ", " + item.data + ", " + item.data_num + "\n";
}
txt.SetText( s );
}
But the above sample only works for SELECT results on the specific table with the fields "id", "data" and "data_num".
How can I make this function generally usable?
How can I loop through the fields to build the string? Or is there a method / function to write a complete
into a string or array?
I tried
results.rows.item(i).toString();
but it didn't work.
Another problem is that
shows
[object Object] in the debug console.
I found nothing suitable on the net.
Thanks in advance.