New Posts New Posts RSS Feed: insert update blobs
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

insert update blobs

 Post Reply Post Reply
Author
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Topic: insert update blobs
    Posted: 06-Sep-2007 at 2:57pm
A possible workaround to the DataRowState is to modifiy the ModTs property and set it to the current time.  In this little app, it shouldn't have any negative ramifications (beware: possible concurrency issues in larger apps).  That sets the state to Modified; except, the picture does not update, now.  Quite odd.  I comment out the update of ModTs and, now, the picture changes.  Another stumper.
 
***Fixed:  I moved the update of the ModTs before the image was set on the picturebox.  Now, on to the ImageToDatabase class.  Why was this left out of DevForce?  It seems so elementary.


Edited by Linguinut - 06-Sep-2007 at 3:03pm
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:49pm
My example primarily shows how to assign an arbitrary photo to an individual and display it.  To save it you should convert it back to a blob and save it.  To do this, you need to write an ImageTobytes utility.

Edited by davidklitzke - 06-Sep-2007 at 2:50pm
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:38pm
Is this the proper syntax?
 
Employee mCurrentEmp = (Employee)mEmpSource.Current;
mCurrentEmp.RowState = DataRowState.Modified;
 
**Nope--the RowState property is read-only.
Interesting. 


Edited by Linguinut - 06-Sep-2007 at 2:39pm
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:33pm
Sorry for my ignorance, but what is the syntax for setting the datarowstate to modified on the current entity?  I assume, since you specified that I would need to figure out how to save to the database, that DevForce will not save the image to the database once the save method is called on the persistence manager?  So, if you could provide the syntax, I'll try to wire up the actual image save routine.
 
Thanks.
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:12pm

The object (i.e., the employee) won't get saved unless its datarowstate gets set to MODIFIED.  Since the photo is readonly, it doesn't have a setter'

Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:11pm
Ouch!  I imagine that the issue is the underlying database.  Different databases handle the storage of images differently, I suppose; therefore, IdeaBlade decided not to implement this piece of the puzzle, yet.  Is that right?
 
In the meantime, I am not sure what you mean by "setter".  And, why doesn't the cached entity change?  If I change a picture on one entity, move to the next entity, then back again, the picture always reverts back to the one in the database.  What else might be going on here, behind the scenes?
 
Thanks for your help!!
 
(I am casting my vote to move this feature up the priority list.  This ranks right behind CAB templates/wizards, for me.)
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:01pm
You are correct.
 
The .NET PictureBox (and also the corresponding controls in DevExpress and Infragistics) are readonly controls.
 
However, that is not to say that with a little work, you couldn't get some update and save capability.
 
(1) You'll need a setter for the PictureBox control, and a way to set the DataRow state to Modified
 
(2) You'll need a way to save the new bitmap to the database.
 
There is currently a low priority feature request in our Bug Tracking system to do this work.
 
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 1:22pm
I added drag/drop to the form and was not able to get any new images dropped onto the form to update the database, either.  If the image property of the picturebox changes, shouldn't the databindings see that and consider it a change to the entity?
Back to Top
mw243270 View Drop Down
Newbie
Newbie


Joined: 05-Sep-2007
Location: United States
Posts: 2
Post Options Post Options   Quote mw243270 Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 12:32pm

Thanks for the reply.

The example does indeed change the pic out, but "Save" doesn't recognize anything as being changed.

Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 10:21am
I have attached a very simple solution that has a "Change Picture" button.  When you click this button, it changes the picture of Nancy Davolio to a picture of Margaret Peacock.
 
 
Back to Top
mw243270 View Drop Down
Newbie
Newbie


Joined: 05-Sep-2007
Location: United States
Posts: 2
Post Options Post Options   Quote mw243270 Quote  Post ReplyReply Direct Link To This Post Posted: 05-Sep-2007 at 6:40pm

In the sample tutorial applications I don't see any mention of how to insert or update the employee pictures stored as blobs in the database. Can anyone provide insight on how to accomplish this?

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down