Dear Jonathon:
I suffered to no end trying to find an example that really worked or
way to do this until last week. I hope these examples help you. They
are based on working code, not just made up:
Saving the picture in the database
I have a canvas that gets a picture dragged and dropped on top of it.
That picture gets saved into a picture property called myPic. I have
the database column (here, thePhoto) defined as a blob. In the
canvas's lostFocus event, I retrieve the record shown on the screen
and update the blob column to contain the picture.
rs = app.db.SQLSelect("select * from mytable where rowID = " +
cstr(recRowID))
rs.edit
rs.field("thePhoto").JPEGValue = myPic // put the picture
constant into "thePhoto" blob in the database
rs.update
... error checking
db.commit
... more error checking...
Retrieving the picture from the database
For example, I use this in a listbox and put the picture in a canvas.
The person clicks the product name in the listbox and I retrieve the
picture and other items in the change event.
rs = app.db.SQLSelect("select rowID,* from mytable where
itemName = 'productName'") // get the record
if rs <> nil and rs.RecordCount > 0 then
myPic = rs.field("thePhoto").JPEGValue // put the blob "thePhoto"
from the database into the picture property myPic
drawNScale(myPic,canvasName) // draw the picture onto a canvas. I
have a method that draws and scales it and writes to the appropriate
canvas.
///
end if
I hope this helps you. It really is simple to do once you know how._______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>