WebDB - For each Column, in Each Row
-
27-10-2019 - |
Question
in webDB, EG: HTML5 SQLLite
How can I do the following:
For i = 0 To RS.Fields.Count -1
Response.Write "Field Name: " & RS.Fields(i).Name & "<br>"
Response.Write "Field Value: " & RS(i) & "<br>"
Next
If, at all...
Or, another question would be, how can I iterate the columns themselves and optimally, retrieve the columns name.
Solution
I found the answer
function showQueryResults(tx, r) {
// alert("showing [" + r.rows.length.toString() + "] query results");
var rs = null;
var $tr, $td;
var $t = $("<table border='1' cellpadding='2 cellspacing='0' />");
if (r.rows.length > 0) {
rs = r.rows.item(0);
$tr = $("<tr />");
$.each(rs, function (key, val) {
$tr.append($("<th>" + key + "</th>"));
});
$t.append($tr);
for (var i = 0; i < r.rows.length; i++) {
rs = r.rows.item(i);
$tr = $("<tr />");
$.each(rs, function (key, val) {
$tr.append($("<td>" + rs[key] + "</td>"));
});
$t.append($tr);
$tr = null;
};
};
$("#formHolder").children().remove();
$("#formHolder").append($t).show();
$t = null;
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow