NetTalk Central

Author Topic: Displaying Image from SQL Blob Field  (Read 3622 times)

ProAssist

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Displaying Image from SQL Blob Field
« on: December 12, 2016, 02:02:36 PM »
I am trying to display an image from a SQL blob field.  The blob contains the full size image.  I think a browse with a child update memory form could display the full size image each time the user selects a row from the browse.  Do I extract the blob in the webhandler procedure?  Do I load the blob into a stringtheory string? How do I display the string containing the image?

Thanks

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Displaying Image from SQL Blob Field
« Reply #1 on: December 12, 2016, 07:47:26 PM »
Hi Pro,

so to be clear, you want a browse on say one side of the page, and an image on the other.
Then as the user highlights a row in the browse the image displays?
Sort of what ABC calls a "hot field".

This is straight-forward to do, but there are some subtleties in play because of the way browsers do images.
I suggest we chat about this at this Thursday's webinar and I can show you the pieces you need to put together.

Hints: You'll have a form, withh 2 fields, the browse and the image.
On a row selection of the browse you'll reset the image control to a new _name_.
Then in web handler you'll "see" that name in _SendFile, and load the appropriate table row, and serve the blob.

Cheers
Bruce

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Displaying Image from SQL Blob Field
« Reply #2 on: December 13, 2016, 01:45:35 PM »
Not sure if this helps, but here's the pseudo code I've used to serve blobs.

In the _SendFile embed like Bruce says, if p_Filename is what you are looking for:

Code: [Select]
self.ForceNoCache=0
self.HeaderDetails.CacheControl=''
self.ReplyContentType='image/jpeg'
self.SendMemory(loc:Image_Blob,loc:Image_Size)
dispose(loc:Image_Blob)

You also need to then skip out of the template PARENT._SendFile(p_FileName,p_header) call that comes directly after the embed in _SendFile, wrap it in an "else / end" statement.

In data somewhere:

Code: [Select]
loc:Image_Blob &string
loc:Image_Size long
Cheers,

Stu Andrews

ProAssist

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Displaying Image from SQL Blob Field
« Reply #3 on: December 14, 2016, 03:49:24 AM »
Thanks for the pseudo code Stu - I inserted it just above the parent call but I am getting an unknown procedure name on the self.SendMemory statement.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Displaying Image from SQL Blob Field
« Reply #4 on: December 15, 2016, 03:37:45 AM »
see FileDownload example for sending a file from a blob.

cheers
Bruce