It is currently Sat Mar 06, 2021 3:29 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: SQLite and Blob - SOLVED -
PostPosted: Thu Nov 28, 2019 7:54 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 23, 2014 12:17 am
Posts: 107
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?

Code:
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)
  ;


Last edited by deanathpc on Fri Nov 29, 2019 4:21 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite and Blob
PostPosted: Thu Nov 28, 2019 8:33 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3413
Location: Boston, MA
Can you make a working example with :memory: connection? The problem usually becomes clear when simplifying the code.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite and Blob - SOLVED -
PostPosted: Fri Nov 29, 2019 4:22 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 23, 2014 12:17 am
Posts: 107
This has been resolved. I walked away from it for a couple of hours after looking at it for hours..

Finally saw the FinishedQuery in the middle of the routine.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye