'NO SUCH TABLE' HTC Problem with SQLite?!? HELP!

Cranx

Member
Licensed User
Longtime User
Hello all,

AmI the only one having this trouble with SQLite using b4a and HTC?

I am trying to create an app that looks at a SQLite db, but am getting the 'no such table' error message when trying to compile and run on an HTC Desire Z.

It seems it is a common fault with htc phones and have found a java solution but not sure how to implement the solution into B4A

See on this link:

You will also see the java solution to this on this link.

Does anyone have the same problem?

Or can anyone help please been stuck for weeks! tried everything!
 

eps

Expert
Licensed User
Longtime User
No problems on my Desire HD.

I would suggest an implementation problem. Try clearing data and cache for the App in question, especially if you added the table you can't seem to find since the database was created.

I have implemented a variable to handle changing the database structure between App versions. I think Klaus used a database table to handle this.. See DBUtils or something similar..
 
Upvote 0

Cranx

Member
Licensed User
Longtime User
Still Stuck!

Thanks guys, but tried droptable to clear the cache, but hasn't worked.

Erel the log is as follows:
B4X:
LogCat connected to: SH11NRT00330
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


DropTable: DROP TABLE IF EXISTS [plof]
Exisits
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DropTable: DROP TABLE IF EXISTS [plof]
Exisits
running waiting messages (1)
main_myabbarcode_barcodefound (B4A line: 49)
cur = SQL.ExecQuery2("SELECT field3 FROM plof WHERE _id=?",Array As String(5900852171444))

android.database.sqlite.SQLiteException: no such table: plof: , while compiling: SELECT field3 FROM plof WHERE _id=?
   at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
   at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
   at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
   at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
   at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
   at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
   at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1417)
   at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1387)
   at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:107)
   at com.multibuyer.ordertek.main._myabbarcode_barcodefound(main.java:366)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:89)
   at com.AB.ABZxing.ABZxing$1.ResultArrived(ABZxing.java:96)
   at anywheresoftware.b4a.BA$2.run(BA.java:313)
   at anywheresoftware.b4a.BA.setActivityPaused(BA.java:263)
   at com.multibuyer.ordertek.main.afterFirstLayout(main.java:88)
   at com.multibuyer.ordertek.main.access$100(main.java:16)
   at com.multibuyer.ordertek.main$WaitForLayout.run(main.java:72)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:143)
   at android.app.ActivityThread.main(ActivityThread.java:5068)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
   at dalvik.system.NativeStart.main(Native Method)
android.database.sqlite.SQLiteException: no such table: plof: , while compiling: SELECT field3 FROM plof WHERE _id=?
** Activity (main) Create, isFirst = true **


DropTable: DROP TABLE IF EXISTS [plof]
Exisits


** Activity (main) Resume **

my program:

B4X:
Sub Process_Globals
   
Dim SQL As SQL
End Sub

Sub Globals

   Dim ScanBarcodeButton As Button
   Dim myABBarcode As ABZxing
   Dim RRPLabel As Label
   Dim SupplierLabel As Label
   Dim mResult As String

End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      SQL.Initialize(File.DirRootExternal, "sqlwayplof.db", True)
   End If
DBUtils1.DropTable(SQL,"plof")
   If SQL.IsInitialized Then SQL.Close
      Try 
      SQL.Initialize(File.DirRootExternal, "sqlwayplof.db", False)



   dbutils1.CopyDBFromAssets("sqlwayplof.db")
Catch
End Try
If File.Exists(File.DirDefaultExternal,"sqlwayplof.db") Then
Log("Exisits")
Else
Log("does not exists")
End If
   Activity.LoadLayout("orderscreen")      
         RRPLabel.Text = mResult
         
   End Sub
   
Sub ScanBarcodeButton_Click
       myABBarcode.ABGetBarcode("myabbarcode", "")
End Sub

Sub myABBarcode_BarcodeFound(barCode As String, formatName As String)
   RRPLabel.Text = barCode
   
   mResult = barCode
Dim cur As Cursor
cur = SQL.ExecQuery2("SELECT field3 FROM plof WHERE _id=?",Array As String(5900852171444)) 


End Sub

Sub myABBarcode_Canceled
    Msgbox("Canceled","")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

DBUtils module is DBUtils1 btw

Very messy code I know just trying to learn :(
 
Upvote 0

Cranx

Member
Licensed User
Longtime User
PS ignore:

dbutils1.CopyDBFromAssets("sqlwayplof.db")
forgot to take it out before copying post...

Any help will be much appreciated!
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Drop table?

I would just go to Settings .. Apps .. Manage and then select the App and clear cache and data there. This is all done within Android.
 
Upvote 0

Cranx

Member
Licensed User
Longtime User
guys,

Just to say it is now fixed.

Thanks for all of your help. I had a problem when I was creating the databse with sqllite browser.

I rewrote the code, and created a database using firefox's sqlite manager addon.

and it worked!!!

Thanks!
 
Upvote 0
Top