Hi All,
I have a query re: SQL db file.
In my project I attempted to cut corners by using an existing DataBase file but came to grief when I changed it's name. To try to track the problem I used Klaus' SQLiteLight2 example.
In the IDE Files tab I changed persons.db to persons1.db and then changed all occurrences of persons.db in the code.
When I open the APP I get the following Log:
Which is telling me persons1 does not exist. It does exist.
I can't see why a name change such as this should cause problems unless I miss changing the name somewhere. I am sure I have not missed anything.
Regards Roger
The two Subs involved are below:
I have a query re: SQL db file.
In my project I attempted to cut corners by using an existing DataBase file but came to grief when I changed it's name. To try to track the problem I used Klaus' SQLiteLight2 example.
In the IDE Files tab I changed persons.db to persons1.db and then changed all occurrences of persons.db in the code.
When I open the APP I get the following Log:
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_executehtml (java line: 452)
android.database.sqlite.SQLiteException: no such table: persons1 (code 1): , while compiling: SELECT FirstName As [First name], LastName As [Last name], City FROM persons1
Which is telling me persons1 does not exist. It does exist.
I can't see why a name change such as this should cause problems unless I miss changing the name somewhere. I am sure I have not missed anything.
Regards Roger
The two Subs involved are below:
B4X:
Private Sub ShowTable
Private Query As String
Query = "SELECT FirstName As [First name], LastName As [Last name], City FROM persons1"
'depending if the filter is active or not we add the filter query at the end of the query
'the filter query is defined in the Filter Activity
If Filter.flagFilterActive = False Then
btnFilter.Text = "Filter" 'change the text in the Filter button
Else
Query = Query & Filter.Query
btnFilter.Text = "UnFilter" 'change the text in the Filter button
End If
'displays the database in a table
wbvTable.LoadHtml(ExecuteHtml(SQL1, Query, Null, True))
ReadDataBaseRowIDs
End Sub
B4X:
Private Sub ExecuteHtml(SQL As SQL, Query As String, StringArgs() As String, Clickable As Boolean) As String
Private ResultSet1 As ResultSet
If StringArgs <> Null Then
ResultSet1 = SQL.ExecQuery2(Query, StringArgs)
Else
ResultSet1 = SQL.ExecQuery(Query)
End If
Private 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><tr>").Append(CRLF)
For i = 0 To ResultSet1.ColumnCount - 1
sb.Append("<th>").Append(ResultSet1.GetColumnName(i)).Append("</th>")
Next
sb.Append("</tr>").Append(CRLF)
Private row As Int
row = 0
Do While ResultSet1.NextRow
If row Mod 2 = 0 Then
sb.Append("<tr>")
Else
sb.Append("<tr class='odd'>")
End If
For i = 0 To ResultSet1.ColumnCount - 1
sb.Append("<td>")
If Clickable Then
sb.Append("<a href='http://").Append(i).Append(".")
sb.Append(row)
sb.Append(".stub'>").Append(ResultSet1.GetString2(i)).Append("</a>")
Else
sb.Append(ResultSet1.GetString2(i))
End If
sb.Append("</td>")
Next
sb.Append("</tr>").Append(CRLF)
row = row + 1
Loop
ResultSet1.Close
sb.Append("</table></body></html>")
Return sb.ToString
End Sub