Real Software Forums
http://forums.realsoftware.com/

Retrieving a photo from RealSQLDatabase
http://forums.realsoftware.com/viewtopic.php?f=3&t=47703
Page 1 of 1

Author:  RobertLob [ Thu Apr 25, 2013 1:10 pm ]
Post subject:  Retrieving a photo from RealSQLDatabase

I have some .jpeg photos stored as binary data string in a REALSQLDatabase. They were put into the database using an RB Desktop App. They are there, and show up using SQLite Manager.

I need to retrieve these photos in a Web App and display in a WebCanvas or WebImageView control.

I can get the binary string out using:
imgData = cur.Field("bin_data").StringValue   //binary picture data

but can't figure out how to get it to display in the WebCanvas or WebImageView.

I have also tried
imgData = cur.Field("bin_data").PictureValue   //binary picture data

but that always gives me an "Unsupported Format Exception"

Anyone have a solution or example code?

Author:  charonn0 [ Thu Apr 25, 2013 1:16 pm ]
Post subject:  Re: Retrieving a photo from RealSQLDatabase

You can use the Picture.FromData to convert raw binary data into a Picture object:
imgData = cur.Field("bin_data").StringValue
Dim Pic As Picture = Picture.FromData(imgData)

Author:  RobertLob [ Thu Apr 25, 2013 2:37 pm ]
Post subject:  Re: Retrieving a photo from RealSQLDatabase

Charonn0-

Thanks. This also gives me an "Unsupported Format Exception"

Is there a difference in the binary format of a Desktop App picture stored in the database and the binary format that a Web App needs to retrieve it?

The photos are dragged and dropped to a canvas in the Desktop Application. Scaled to size, and then assigned to a Desktop Canvas backdrop. In a Save pushbutton, the Canvas.Backdrop is saved to the database using Bailey's PictureToString function.

In the Desktop app, I can retrieve the pictures using Bailey's StringToPicture function just fine.

But in the Web app, I keep getting the Format Exception. There must be a step I'm missing that converts the desktop binary string into something that the web app can use. Any Idea?

Author:  charonn0 [ Thu Apr 25, 2013 3:11 pm ]
Post subject:  Re: Retrieving a photo from RealSQLDatabase

I'm not familiar with Bailey's PictureToString function. My suggestion relies on the binary data being manipulated being the raw binary picture data, such as that returned by the built-in Picture.GetData function.

Author:  RobertLob [ Thu Apr 25, 2013 5:57 pm ]
Post subject:  Re: Retrieving a photo from RealSQLDatabase

I think it's Mike Bailey, Database Tip #11 , and in several other forum entries I've studied.

It seems to work great from a Desktop App, but I can't seem to retrieve the photo using a Web App.

This gives unsupported format exception, probably because Web Apps use WebPicture instead of just Picture:
imgData = cur.Field("bin_data").StringValue
Dim Pic As Picture = Picture.FromData(imgData)


When I change the dim to WebPicture like this:
imgData = cur.Field("bin_data").StringValue
Dim Pic As WebPicture = WebPicture.FromData(imgData)


Rb complans that "FromData" doesn't exist.

I'll see what I can do with Picture.GetData.

Thanks.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/