Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Drag and Drop - Update Database

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
esanabia



Joined: 29 Sep 2008
Posts: 23

PostPosted: Mon Aug 17, 2009 8:02 pm    Post subject: Drag and Drop - Update Database Reply with quote

I'm unclear how the drag and drop functionality works with the Virtual Tree. I want the "ParentID" field to be updated after the user moves a node to another location in the tree. Do I add code to the "DragDrop" event to update the database or is it handled by the "UpdateCommand" in my OleDbDataAdapter?

Thanks for the help.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Aug 17, 2009 10:43 pm    Post subject: Reply with quote

Are you binding to data from a DataSet?

If so look at the DataSetBrowser sample project. This supports drag and drop of orders between customers. To enable drag and drop for VirtualTrees that use DataSet binding all you need to do is to enable the AllowDrag and AllowDropOnRow properties of the RowBindings (in the Virtual Tree editor). Virtual Tree will automatically update the (in memory) dataset when rows are dragged and dropped - however to persist these changes back to the database you need to use the DataAdaptor.Update method. See the _commitItem_Click method in the sample project for an example of doing this.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
esanabia



Joined: 29 Sep 2008
Posts: 23

PostPosted: Mon Aug 17, 2009 11:42 pm    Post subject: Reply with quote

My tree's DataSource property is set to a DataView. I'm getting the following error when I try to Commit the changes...

"Error committing to database: Concurrency violation: the Updatecommand affected 0 of the expected 1 records."

I'm pretty sure my UpdateCommand and Parameters are correct in my DataAdapter.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Aug 18, 2009 12:25 am    Post subject: Reply with quote

This is almost certainly an ADO.NET issue - so unfortunately we can't give you a lot of help with it. If you google on this topic you will see you are not alone with this error. See the link below for some possible causes:

http://bytes.com/topic/visual-basic-net/answers/433337-concurrency-violation
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
esanabia



Joined: 29 Sep 2008
Posts: 23

PostPosted: Tue Aug 18, 2009 3:43 am    Post subject: Reply with quote

I updated my UpdateCommand.CommandText in my DataAdapter and now it's working. Thanks for the help!
Back to top
View user's profile Send private message
morgenweck



Joined: 09 Jun 2010
Posts: 21

PostPosted: Wed Jun 30, 2010 5:50 pm    Post subject: Reply with quote

Is there an event that can be called after the drop is completed? It seems that the DragDrop or Rowdrop is a bit to soon since the drop row is not commited yet. I would like to auto update rather than to click commit
Thanks
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jun 30, 2010 10:58 pm    Post subject: Reply with quote

You can handle the RowDrop event - but if you do then this means you are taking control of the drop, so to have the default behaviour you need call the OnDrop method of the appropriate RowBinding as shown below:

Code:
Private Sub _virtualTree_RowDrop( ByVal sender As System.Object,  ByVal e As RowDropEventArgs) Handles _virtualTree.RowDrop
    Dim sBinding as RowBinding = _virtualTree.GetBindingForRow(e.Row)
    sBinding.OnDrop(e.Row, e.DropLocation, e.Data, e.DropEffect)
    ' now do what you want
End Sub

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group