Hi All,
Another problem with SQL.
First up, the App was running and then I did decided to check a clean install.
I deleted all entries, uninstalled the App from the phone and installed it as a completely new App.
I am now locked in to this error.
I have tried editing the Table, tried bringing in a database file from elsewhere and editing it. No go.
I read that the program can't find the "sites" table although it does show in DB Browser.
NOTE1: The code around SQLLite is largely taken from Klaus' SQLliteLight2 example. This is not the problem, I just note that so you may reference the original.
NOTE2: My App is too large to upload completely, I can't make a simple example because I would need to know the problem to duplicate it. Catch 22
Below is the following Code around the problem.
ShowTable writes the string "Query" which is passed to ExecuteHtml(SQL1,Query, Null, True)
This is a screen shot of sites.db in DB Browser.
Obviously I am again out of my depth so any assistance will be appreciated. My only alternative is to go back to the previous working version and start over.
Regards Roger
Another problem with SQL.
First up, the App was running and then I did decided to check a clean install.
I deleted all entries, uninstalled the App from the phone and installed it as a completely new App.
I am now locked in to this error.
I have tried editing the Table, tried bringing in a database file from elsewhere and editing it. No go.
I read that the program can't find the "sites" table although it does show in DB Browser.
** Activity (main) Create, isFirst = true **
~w:1004,main,144
** Activity (main) Resume **
main_executehtml (B4A line: 2571)
ResultSet1 = SQL.ExecQuery(Query)
android.database.sqlite.SQLiteException: no such table: sites (code 1): , while compiling: SELECT SiteName As [Site Name], Longitude As [Longitude], Latitude as [Latitude] FROM sites ORDER BY UPPER(SiteName) ASC
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1428)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1367)
at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
at horsetrailer.B4A.AntennaBearingTool.main._executehtml(main.java:5737)
at horsetrailer.B4A.AntennaBearingTool.main._showtable(main.java:7578)
at horsetrailer.B4A.AntennaBearingTool.main._activity_resume(main.java:1425)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
NOTE1: The code around SQLLite is largely taken from Klaus' SQLliteLight2 example. This is not the problem, I just note that so you may reference the original.
NOTE2: My App is too large to upload completely, I can't make a simple example because I would need to know the problem to duplicate it. Catch 22
Below is the following Code around the problem.
ShowTable writes the string "Query" which is passed to ExecuteHtml(SQL1,Query, Null, True)
B4X:
Private Sub ShowTable
Private Query As String
Query = "SELECT SiteName As [Site Name], Longitude As [Longitude], Latitude as [Latitude] FROM sites ORDER BY UPPER(SiteName) ASC"
'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) 'This is B4A line 2571, the line that throws the error.
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
This is a screen shot of sites.db in DB Browser.
Obviously I am again out of my depth so any assistance will be appreciated. My only alternative is to go back to the previous working version and start over.
Regards Roger