After spending far too much time with B4A this week (well it is addictive), I cannot see why my modified version of the dbutils library function 'executehtml' won't work.
Instead of displaying columns across, and rows in a list I just want to display one record, column names in column 1 and column contents in row 2. I just cannot see the 'issue'.
The error I get is on line marked xxx, when it tries to add the contents of the column in the table. The string build up to that point is fine, it then tells me that I have
"android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1"
There is only one record in the cursor, I know what it means, but I can;t for the life of me see the 'error'.
I know its one of those forehead slapping moments but I can't see the problem.
Sub ExecuteHtml2(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean) As String
Dim Table As List
Dim cur As Cursor
If StringArgs <> Null Then
cur = SQL.ExecQuery2(Query, StringArgs)
Else
cur = SQL.ExecQuery(Query)
End If
Limit = 1
Dim sb As StringBuilder
sb.Initialize
sb.Append("<html><body>").Append(CRLF)
sb.Append("<style type='text/css'>").Append(HtmlCSS).Append("</style>").Append(CRLF)
sb.Append("<table>").Append(CRLF)
For i = 0 To cur.ColumnCount-1
If i Mod 2 = 0 Then
sb.Append("<tr>")
Else
sb.Append("<tr class='odd'>")
End If
sb.Append("<td>").Append(cur.GetColumnName(i)).Append("</td>")
xxx sb.Append("<td>").Append(cur.GetString2(i)).Append("</td>")
sb.Append("</tr>").Append(CRLF)
Next
cur.Close
sb.Append("</table></body></html>")
Return sb.ToString
End Sub
Instead of displaying columns across, and rows in a list I just want to display one record, column names in column 1 and column contents in row 2. I just cannot see the 'issue'.
The error I get is on line marked xxx, when it tries to add the contents of the column in the table. The string build up to that point is fine, it then tells me that I have
"android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1"
There is only one record in the cursor, I know what it means, but I can;t for the life of me see the 'error'.
I know its one of those forehead slapping moments but I can't see the problem.
Sub ExecuteHtml2(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean) As String
Dim Table As List
Dim cur As Cursor
If StringArgs <> Null Then
cur = SQL.ExecQuery2(Query, StringArgs)
Else
cur = SQL.ExecQuery(Query)
End If
Limit = 1
Dim sb As StringBuilder
sb.Initialize
sb.Append("<html><body>").Append(CRLF)
sb.Append("<style type='text/css'>").Append(HtmlCSS).Append("</style>").Append(CRLF)
sb.Append("<table>").Append(CRLF)
For i = 0 To cur.ColumnCount-1
If i Mod 2 = 0 Then
sb.Append("<tr>")
Else
sb.Append("<tr class='odd'>")
End If
sb.Append("<td>").Append(cur.GetColumnName(i)).Append("</td>")
xxx sb.Append("<td>").Append(cur.GetString2(i)).Append("</td>")
sb.Append("</tr>").Append(CRLF)
Next
cur.Close
sb.Append("</table></body></html>")
Return sb.ToString
End Sub