Reading a SQLite record
Posted: Fri Sep 29, 2023 9:22 am
Hello everyone,
I've just started learning about SQLite. I've written PureBasic code that successfully reads an SQLite file from disk and displays the records in a ListIconGadget with the record ID in the first column followed by other fields in additional columns. That part works well but I'm needing help with the next stage of reading and displaying record fields.
My ultimate intention is that I click on a row in the ListIconGadget and then click a button that will open a window and display the field entries for that record.
My record reading code so far is:
The code above gives the correct ListIconGadget row number and determines the record ID from the first column but Debug GetDatabaseString(sqliteNo, 2) does not print the contents of that field. This is just one of many attempts to read the record from the file so I'm wondering if someone could help me please.
Thanks in advance
I've just started learning about SQLite. I've written PureBasic code that successfully reads an SQLite file from disk and displays the records in a ListIconGadget with the record ID in the first column followed by other fields in additional columns. That part works well but I'm needing help with the next stage of reading and displaying record fields.
My ultimate intention is that I click on a row in the ListIconGadget and then click a button that will open a window and display the field entries for that record.
My record reading code so far is:
Code: Select all
rowNumber = GetGadgetState(ligFrmMain) ;Determine the row number in the ListIconGadget
readRecordIDStr = GetGadgetItemText(ligFrmMain, rowNumber, 0) ;Read the Record ID which is stored on the first column
OpenDatabase(sqliteNo, "myData.db", "", "") ;Open the database file
SetDatabaseString(sqliteNo, 0, readRecordIDStr) ;Set the record ID for data binding in the query
query.s = "SELECT * FROM myTable where id = ?" ;Make the query string
DatabaseQuery(sqliteNo, query)
Debug GetDatabaseString(sqliteNo, 2)
CloseDatabase(sqliteNo)
Thanks in advance