SQLite and Blob - SOLVED -
Posted: Thu Nov 28, 2019 7:54 pm
Here is some code that just will not populate the ListIcon with more than one (1) record. I use this code for other data with zero problems. Is it because of the BLOB that it won't populate more than one record?
I can change the select statement and pull each record number individually with zero issues. Just one record though. I am guessing I am missing something here and I just haven't found it yet.
If this is a BLOB specific type of thing is there a work around?
I can change the select statement and pull each record number individually with zero issues. Just one record though. I am guessing I am missing something here and I just haven't found it yet.
If this is a BLOB specific type of thing is there a work around?
Code: Select all
If DatabaseQuery(1, "SELECT * FROM images where relatedfirearm='" + GetGadgetText(#Gadget_Form_FirearmAddEdit_String_Name) + "' ORDER BY deleted ASC")
While NextDatabaseRow(1) > 0
firearmpicdoc_RecNo = GetDatabaseLong(1,0)
firearmpicdoc_name$ = GetDatabaseString(1, 1)
firearmpicdoc_description$ = GetDatabaseString(1, 2)
firearmpicdoc_relatedto$ = GetDatabaseString(1, 3)
pictureSize = DatabaseColumnSize(1, 4)
*picture = AllocateMemory(pictureSize)
GetDatabaseBlob(1, 4, *picture, pictureSize)
CatchImage(1, *picture, pictureSize)
ResizeImage(1, 140, 130)
;SetGadgetState(#Gadget_Form_FirearmAddEdit_Image_Firearm_Image1, ImageID(1))
FinishDatabaseQuery(1)
FreeMemory(*picture)
firearmpicdoc_deleted$ = GetDatabaseString(1, 5)
firearmpicdoc_string$ = Str(firearmpicdoc_RecNo) + Chr(10)
firearmpicdoc_string$ + firearmpicdoc_name$ + Chr(10)
firearmpicdoc_string$ + firearmpicdoc_description$ + Chr(10)
firearmpicdoc_string$ + firearmpicdoc_deleted$
AddGadgetItem(#Gadget_Form_FirearmAddEdit_ListIcon_Firearms_PhotosDocs, fadn, firearmpicdoc_string$) ; Give the row an identifiable number of 0 to start
SetGadgetItemData(#Gadget_Form_FirearmAddEdit_ListIcon_Firearms_PhotosDocs, fadn, Val(firearmpicdoc_string$)) ; Links identifiable number with database ID for PullIssue()
;
EvenOddTest2 = Val(Right(Str(fadn),1))
If EvenOddTest2 = 0 Or EvenOddTest2 = 2 Or EvenOddTest2 = 4 Or EvenOddTest2 = 6 Or EvenOddTest2 = 8
SetGadgetItemColor(#Gadget_Form_FirearmAddEdit_ListIcon_Firearms_PhotosDocs, fadn, #PB_Gadget_BackColor, $E6D8AD, -1)
EndIf
If firearmpicdoc_deleted$ = "TRUE"
SetGadgetItemColor(#Gadget_Form_FirearmAddEdit_ListIcon_Firearms_PhotosDocs, fadn, #PB_Gadget_BackColor, $0000FF, 0)
EndIf
Debug "Pic Doc counter: " + Str(fadn)
fadn + 1 ; Increment for next identifiable number
Wend
;StatusBarText(#StatusBar_Form1, 0, Str(fadn) + " Firearm(s) found.")
; An alternate way of counting items in the gadget
CountResult = CountGadgetItems(#Gadget_Form_FirearmAddEdit_ListIcon_Firearms_PhotosDocs)
Debug "CountGadget found: " + Str(CountResult) + " items in the ListIconGadget"
Else
MessageRequester("Photo/Doc Error", "Can't pull photos / doc records: " + DatabaseError(), #PB_MessageRequester_Error)
EndIf
;
FinishDatabaseQuery(1)
;