demonio_jack Member Licensed User Jun 6, 2020 #1 Hi again: I am sure this is a classic of this forum, but after searching and finding too many solutions that I cannot implement in my code as an efficient solution, I ask you for help to see if anyone has a simple example to help me with this: I have an SQLite database that I am reading from my device, in it I have TESTS, QUESTIONS AND ANSWERS. As in college or university, the user must take an exam that has a certain number of questions and each of them has 5 possible answers (only one is correct). How can I load in memory the TEST, its QUESTIONS and the ANSWERS in some type of variable to go through them and display them on the screen? Thank you very much as always. ? Demonio
Hi again: I am sure this is a classic of this forum, but after searching and finding too many solutions that I cannot implement in my code as an efficient solution, I ask you for help to see if anyone has a simple example to help me with this: I have an SQLite database that I am reading from my device, in it I have TESTS, QUESTIONS AND ANSWERS. As in college or university, the user must take an exam that has a certain number of questions and each of them has 5 possible answers (only one is correct). How can I load in memory the TEST, its QUESTIONS and the ANSWERS in some type of variable to go through them and display them on the screen? Thank you very much as always. ? Demonio
A Alex_197 Well-Known Member Licensed User Longtime User Jun 6, 2020 #2 Why to keep them in memory - why not getting them from your DB? But you can load them into lists and use them like recordsets Upvote 0
Why to keep them in memory - why not getting them from your DB? But you can load them into lists and use them like recordsets
demonio_jack Member Licensed User Jun 6, 2020 #3 Alex_197 said: Why to keep them in memory - why not getting them from your DB? But you can load them into lists and use them like recordsets Click to expand... It's a good question and that's what I've been doing. I am looking for a more efficient way and not have to be accessing the database (file) every so often. Thank you very much Alex for the answer (maybe it could be the best solution for now). Upvote 0
Alex_197 said: Why to keep them in memory - why not getting them from your DB? But you can load them into lists and use them like recordsets Click to expand... It's a good question and that's what I've been doing. I am looking for a more efficient way and not have to be accessing the database (file) every so often. Thank you very much Alex for the answer (maybe it could be the best solution for now).
A Alex_197 Well-Known Member Licensed User Longtime User Jun 6, 2020 #4 demonio_jack said: It's a good question and that's what I've been doing. I am looking for a more efficient way and not have to be accessing the database (file) every so often. Thank you very much Alex for the answer (maybe it could be the best solution for now). Click to expand... Keep in mind that while it seems faster than taking it from the database you consume more memory which is no good if you have a lot of records. Upvote 0
demonio_jack said: It's a good question and that's what I've been doing. I am looking for a more efficient way and not have to be accessing the database (file) every so often. Thank you very much Alex for the answer (maybe it could be the best solution for now). Click to expand... Keep in mind that while it seems faster than taking it from the database you consume more memory which is no good if you have a lot of records.
B Brian Dean Well-Known Member Licensed User Longtime User Jun 7, 2020 #5 How can I load in memory the TEST, its QUESTIONS and the ANSWERS in some type of variable Click to expand... I am not quite sure what you are asking here, but I assume that you are putting your test questions into an object; for instance ... B4X: Copy Type test = (question As String, answers As Array(5) As String, correct As Int) Then you can move test questions around as single objects, or use a List to build a subset of test questions. But still best to keep the main stock of test questions in a database. Upvote 0
How can I load in memory the TEST, its QUESTIONS and the ANSWERS in some type of variable Click to expand... I am not quite sure what you are asking here, but I assume that you are putting your test questions into an object; for instance ... B4X: Copy Type test = (question As String, answers As Array(5) As String, correct As Int) Then you can move test questions around as single objects, or use a List to build a subset of test questions. But still best to keep the main stock of test questions in a database.