Android Question The app crashed doing an Insert in a sqlite db...

Luis Felipe

Member
Licensed User
Longtime User
Hello everybody,

My problem is that my app crashed when I try to do an Insert in a sqlite db.
I've checked every field before inserting them in order to see if one is empty for example or if the length is not correct, etc...
Any help apreciated.
Thank you.

Best regards,

Lou
 

Attachments

  • SurveyTravel.zip
    17.5 KB · Views: 58

mc73

Well-Known Member
Licensed User
Longtime User
You create a table named 'viajeros', and then you tried inserted data to a table named 'persons'.
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
You create a table named 'viajeros', and then you tried inserted data to a table named 'persons'.
Thank you so much mc73.
I'm going to modify that right now. It was about to turn me crazy about that.
I don't know where you're living but if you come to the south-east of Spain, you're invited to a spanish beer ;-).
Have a nice day.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
You create a table named 'viajeros', and then you tried inserted data to a table named 'persons'.
I'm doing another Query but that time with the right table "viajeros" but the label LblNumEnc doesn't show any data. What am I missing ?
Thank you.

B4X:
Sub ContarEncuestas
    Dim Row As Int
    Dim Cursor1 As Cursor
    'Vamos a contar cuantas encuestas no se han enviada
    Cursor1 = SQL1.ExecQuery("SELECT COUNT(*) FROM viajeros WHERE ca_enviado='N'")
    If Cursor1.RowCount > 0 Then                        'si hay encuestas sin enviar
        Row = Cursor1.RowCount                            'set the row count variable
    Else
        Row = 0                                       
    End If
    LblNumEnc.Text = Row
    Cursor1.Close                                        'close the cursor, we don't need it anymore
End Sub
 

Attachments

  • SurveyTravel2.zip
    21.5 KB · Views: 65
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What am I missing ?

You need to load the layout first before you can use the objects in it.

change
B4X:
ContarEncuestas
Activity.LoadLayout("MenuPrincipal")
to
B4X:
Activity.LoadLayout("MenuPrincipal")
ContarEncuestas
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
You need to load the layout first before you can use the objects in it.

change
B4X:
ContarEncuestas
Activity.LoadLayout("MenuPrincipal")
to
B4X:
Activity.LoadLayout("MenuPrincipal")
ContarEncuestas
Changed it but now even the first screen doesn't show :-(. Quite sure my Select is good...
I'm totally stucked!
Thank for your help DonManfred.
(reload the source code because I simplified the worflow of the layouts)
 

Attachments

  • SurveyTravel3.zip
    21 KB · Views: 56
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But, i must be honestly. I don´t know whether the old packagename was the issue or not.
I just had in mind that a packagename should have two dots... So i tried and then it works.
if you change the folder to file.DirRootExternal for example then it works too. But with dirinternal it did not work at the beginning for me here. and i did´nt found the "internal dir" on my (rooted) device. So i thought there must be something wrong and i checked the packagename. Then i tried to use a name with two dots and then it works here. :)
Kind of magic? I did not expect this result :D
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
But, i must be honestly. I don´t know whether the old packagename was the issue or not.
I just had in mind that a packagename should have two dots... So i tried and then it works.
if you change the folder to file.DirRootExternal for example then it works too. But with dirinternal it did not work at the beginning for me here. and i did´nt found the "internal dir" on my (rooted) device. So i thought there must be something wrong and i checked the packagename. Then i tried to use a name with two dots and then it works here. :)
Kind of magic? I did not expect this result :D

DonManfred, you're a magician. Now I can see the counter on the screen. But the result ("0") is not what I was expecting...
Thank you.
 
Upvote 0
Top