Android Question NO TABLE BUT THE TABLE EXISTS :android.database.sqlite.SQLiteException: no such table: pvpt ...

DALB

Active Member
Licensed User
Hello.

Developing an app for weeks, I run it many times without any problems, bringing new features every week.
This day, it stops running with this arror:

android.database.sqlite.SQLiteException: no such table: pvpt (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM pvpt WHERE pays='France' AND villes='Paris'

What is interesting is that I never changed anything about the pvpt table for a long time. I work on other activities.

My starter declaration is ok, the table pvpt exists from the beginning. I have tested its contents, all is ok.

I also make care with this code:

try catch code:
synt="SELECT * FROM pvpt WHERE pays='France' AND villes='Paris'"
    Try
    curs=Starter.SQL1.ExecQuery(synt)
    curs.Position=0
    Catch
        MsgboxAsync("Pas de table pvpt dans la base !","MANQUE TABLE")
      '  MsgboxAsync("No table pvpt named in the base !","TABLE IS MISSING")
    End Try

curs is declared as Cursor like this:
cursor:
Private Curs as Cursor

What can suddenly make this error ???
What I saw in the forum doesn't fit with my problem for the same error. Here, the tbla pvpt is not reconized.

Thanks much for those who can give me some ideas !
 

Mahares

Expert
Licensed User
Longtime User
give me some ideas
Your syntax looks correct. However, you should declare the cursor inside the sub using: Dim Curs as Cursor and close the cursor immediately after you are done with the query with Curs.Close.
That aside, you should use a parameterized query and Resultset instead of a cursor.
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
Or he added a new table between ! Remove the application from phone or tablet and reinstall it !
 
Upvote 0

DALB

Active Member
Licensed User
Your syntax looks correct. However, you should declare the cursor inside the sub using: Dim Curs as Cursor and close the cursor immediately after you are done with the query with Curs.Close.
That aside, you should use a parameterized query and Resultset instead of a cursor.
Hello, I did it, but the app doesn't recognize the table.

I suspect you are reading the wrong SQLite file or permission issue.
Hello, No, I used it many times without any problem

Or he added a new table between ! Remove the application from phone or tablet and reinstall it !
Hello, Yes, I did it and the problem is still present.

I tried the app on a Xiaomi Redmi 9 and a Lenovo Tablet 803. the table pvpt is not recognized. I can't see why now this table is not recognized.
I look for other ways.
My question is : Why it appears now after many uses ?

Thanks for your help, but the solution is in an other way.
 
Upvote 0

DALB

Active Member
Licensed User
Are you able to copy out the database and examine it whether it is corrupted?
Good idea, I'll do it soon ! Thanks.

I assume you've tested your database with some sqlite viewer to check that the table still exists.

What happen if you run this SQL statement from your app?

B4X:
SELECT name FROM sqlite_master WHERE type ='table' AND name NOT LIKE 'sqlite_%';
Hello, Yes, I did it with 'DB Browser for SLQITE'.
 
Upvote 0

DALB

Active Member
Licensed User
Are you able to copy out the database and examine it whether it is corrupted?
It's ok ! reading the base is ok !

Maybe I'll try to recreate it under an other name to test if it works . Soon !
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I did it with 'DB Browser for SLQITE
have you try to run the command I told you in your app?
You mean SQLite instead of SLQITE' We will blame it on typos. Definitely a good idea to try Jose 's suggestion if you are still looking for the answer to your thread. Here it is complete for you on a platter to try it in your project exactly like it is:
B4X:
Dim rs As ResultSet
    rs = Starter.SQL1.ExecQuery2($"SELECT name FROM sqlite_master WHERE type = ? AND name NOT LIKE ?"$, _
    Array As String ( "table", "sqlite_%"))
    Do While rs.NextRow
        Log("table name " & rs.GetString("name"))
    Loop
    rs.Close
 
Last edited:
Upvote 0

DALB

Active Member
Licensed User
Thanks for everyone for you help.

Any solution worked.
It means that your answers are certainly good, but B4A didn't give me a good issue.
This morning, after a crash of B4A, I restarted it and it works well.
I think there is probably a problem between Windows 10 and B4A (it's not the first time B4A crashes since a year)

So, this error of table reading remains non solved because I iddn't find the technical reasons.
I'm waiting (not really) for an other breakdown to explore more solutions.

Soon.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
I think there is probably a problem between Windows 10 and B4A
Probably a problem between your Windows 10 and B4A, or a lot of people here would be reporting problems, and I don't think this is happening.

It means that your answers are certainly good, but B4A didn't give me a good issue.
What did you get with the Mahare's code in the previous post? You want to explore more solutions, but we don't know the results of your tests, so it's hard continue posting more posible solutions.
 
Upvote 0

DALB

Active Member
Licensed User
Probably a problem between your Windows 10 and B4A, or a lot of people here would be reporting problems, and I don't think this is happening.


What did you get with the Mahare's code in the previous post? You want to explore more solutions, but we don't know the results of your tests, so it's hard continue posting more posible solutions.
The solution of Mahares gave me an error 0:0 and no more. No answer about the fact that B4A recognized the table; It's why I wrote that the answers seem good, but I couln'd have a good description of the error.

And I repeat that I use this app many times before having this error of reading. That 's why I suppose Windows 10 to be at the origin of it.

Thanks José.
 
Upvote 0

DALB

Active Member
Licensed User
wow ! Now as it works, I only can write that I exactly used the Mahares code and the answer in the log was :
B4X:
 error 0:0
without any more text of this description.
I can't give you more about it and I can't reproduce it at this time !
If it comes again, I'll write a thread with these details or send a copy of the screen.
Sorry for this !
 
Upvote 0
Top