Accessing Data Base

walterf25

Expert
Licensed User
Longtime User
Ok, i have been researching for about a week today and so far i have not been able to find a simple example that will show me how to access the data stored in a database file (db) so far all the examples i can find only show me how to create a db file if not created and how to add data to it programatically, all i need is a simple example that will show me how to access the records from a file i created and saved it in my SD card i would like to have 2 buttons to navigate through the records "Previous" and "Next" can anybody please, pretty please help me with this, i actually found one example that comes with the beginners guide but i feel it to be a little too complex for my level, if anyone can please give me an example or point me to where i can find one i will really appreciate it.
Hope i can get some answers here guys.

Thanks,
:sign0163:
 

walterf25

Expert
Licensed User
Longtime User
DataBase

NJDude hi, i familiar with SQL and the command syntax what i'm having a hard time with is the way it is used in the examples i've seen, if i could find the documentation for the DBUtils and SQL libraries i think i would be able to figure it out, but can't find anything but a few examples that don't really help in what i'm trying to achieve, all i need is to be able to read the records and display them on a label one by one, with a "previous" button and a "Next" button.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Ok, is there a way that you can post an example, i can verify that my db file is there, but can you show me one way to load one record and display it on a label please!
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
Here you have another one.

Best regards.


Hi,

I tried to use your example on my database file, but I am getting an error on "No such table" with the emulator.
Attached is my sl3 data file. Could you help?

Thanks
 

Attachments

  • allbasicdata.zip
    1.2 KB · Views: 334
Upvote 0

klaus

Expert
Licensed User
Longtime User
To have a look at it, you should post the whole source code of your current project not only the DB file, so we could see what you have done.
As you get a "No such table" error that means that you are trying to access the DB with a wrong table name.

Best regards.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The program from post #12 is not directly usable for your database.
The program from post #12 looka for an ID, that means it is looking for a primary key, your database doesn't have one.
You could use SQLiteViewer to look at it, it does works.

Best regards.
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
Hi Klaus,


Thanks for your respond. I am new to B4a and was trying to get a feel of SQLite in B4a. My allbasicdata.sl3 file is only 5% of the orginal file which has about 35,000 lines of data. This is what I had tried:

Using your SQLiteSimple tutorial codes and change the database file to my allbasicdata.sl3 and it runs well.
But when a use the orginal data file(about 3mb) it give me a error of

An error has occurred in sub:main_sqltableread(B4A line:432)
Cursor1=SQL1.ExecQuery(txt)android.database.sqlite.
SQLiteException: no such table:CREW:, while compiling:SELECT*FROM CREW ORDER BY SN ASC

I also tried using SQLiteViewer tutorial codes, it give me the same results. ie I am able to view the small data file but UNABLE to find the "table" on the bigger data file?

Does B4a have a max no of data limitations?

Thanks
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
Are you sure that the table name in the big file is really "CREW" ?

Best regards.

Yes, Its converted from a big text file. I deleted 90% of the big text file data before converting into the smaller file.
 
Upvote 0
Top