Android Question scrollView cant connect to Sql database (internal Sql )

nimavao

Member
Hello, I had asked about my problem near week ago and it solved but when I made a new Activity and new layout with scrollview Unfortunatly I faced conecting scrollview and Sql table ,I couldnt figur out how to solve it even I tried so much thus I decided to ask if any body can give me hand in b4x forum.
the problem is in "Content" Activity in line 29 to 32 it doesn't show any thing in scrolView I tried so many method some times it gives me error which it cant find table or string on table and some time it didn't work without any error and I drove crazy . thank you all for help me in advance. 🙏 I attach project here

Content activity - Activity_Create(FirstTime As Boolean):
b Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("booksContent")
    booksContentSv.Panel.LoadLayout ("vontentlable")
    sqlDB.Initialize(File.DirInternal,"inbrcodesConfirm.db",True)
   
    Dim cur As Cursor
    Dim rs As ResultSet
    'Dim strScrolView As String
cur = sqlDB.ExecQuery2 ("SELECT * FROM codeXIIContent WHERE idMaine =?", Array As String ("idMaine"))
    cur.Position = 0

    Label1.Text = cur.GetString("contentId")
End Sub
 

Attachments

  • codexii.zip
    331 KB · Views: 63
Solution
and I drove crazy

I made several corrections to your project so it does not crash any more. I also created the Content module based on your 1st post code snippet. But I made lost of corrections to that module too. It should give you an idea of the notes I made in my previous post. Unzip it and play with it to get to your final project

Mahares

Expert
Licensed User
Longtime User
Also, it's better to create B4XPages projects.

We went through all that in his previous thread already for the same project:

Content" Activity in line 29 to 32 it doesn't show any thing in scrolView
1. As Luca mentioned., you are missing the content activity module.
2. If some of the code you posted in post #1 represents Content activity, you should not be initializing the database there.
3. You should have only initialized in the main activity if firsttime like this:
B4X:
 If FirstTime Then
        sqlDB.Initialize(File.DirInternal,"inbrcodesConfirm.db",True)
    End If
4. Since you are accessing the database and tables in Content activity, you should declare it in the main activity Process_Global using
Public sqlDB As SQL
5. In your content activity, you need to use: cur = Main.sqlDB.ExecQuery2 (.............
6. You are better off resubmitting your project
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
and I drove crazy

I made several corrections to your project so it does not crash any more. I also created the Content module based on your 1st post code snippet. But I made lost of corrections to that module too. It should give you an idea of the notes I made in my previous post. Unzip it and play with it to get to your final project
 

Attachments

  • NimavaoProjectCorrectedbyMahares.zip
    197.2 KB · Views: 79
Upvote 0
Solution

nimavao

Member
I made several corrections to your project so it does not crash any more. I also created the Content module based on your 1st post code snippet. But I made lost of corrections to that module too. It should give you an idea of the notes I made in my previous post. Unzip it and play with it to get to your final project
thank you so much its work believe me that I test it 100 time by 100 method that I thought it could work , I'm going to edit Curser part in Content activity to make it dynamic and I hope I can make it
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
its work believe me that I test it 100 time by 100 method
Since you are new to B4X, if you have interest in using a B4XPages project as opposed to a default project which you are engaged in now, I can rewrite the above project for you using the more preferable way which is B4XPages.. This of course hinges on whether you are already comfortable with what you are doing now and do not want to make any switch at the moment to rock the boat.
In addition, I can make it to use Resultset instead of Cursor, xCustomlistview instead of the old Listview. Normally, with someone new like you,, the community recommends the newer types of projects and methods to stay on top of things. But, the old ways work too, if you are content to stay that way.
 
Upvote 0

nimavao

Member
Since you are new to B4X, if you have interest in using a B4XPages project as opposed to a default project which you are engaged in now, I can rewrite the above project for you using the more preferable way which is B4XPages.. This of course hinges on whether you are already comfortable with what you are doing now and do not want to make any switch at the moment to rock the boat.
In addition, I can make it to use Resultset instead of Cursor, xCustomlistview instead of the old Listview. Normally, with someone new like you,, the community recommends the newer types of projects and methods to stay on top of things. But, the old ways work too, if you are content to stay that way.
thank you for your generosity , I'm civil eng and this project is creating for make an app which include some designe code ,the problem is I am making this app according to an online b4a learning video that created in 2015 .and some variable that teaches in this learning doesn't work (because it made on old b4a generation) I cant change method and switch to b4x form because I want to made search form , add sql from host ,made login ant etc that all of these have been taught in that video
 
Upvote 0
Top