View previous topic :: View next topic |
Author |
Message |
esanabia
Joined: 29 Sep 2008 Posts: 23
|
Posted: Mon Aug 17, 2009 8:02 pm Post subject: Drag and Drop - Update Database |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Aug 17, 2009 10:43 pm Post subject: |
|
|
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 |
|
|
esanabia
Joined: 29 Sep 2008 Posts: 23
|
Posted: Mon Aug 17, 2009 11:42 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Aug 18, 2009 12:25 am Post subject: |
|
|
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 |
|
|
esanabia
Joined: 29 Sep 2008 Posts: 23
|
Posted: Tue Aug 18, 2009 3:43 am Post subject: |
|
|
I updated my UpdateCommand.CommandText in my DataAdapter and now it's working. Thanks for the help! |
|
Back to top |
|
|
morgenweck
Joined: 09 Jun 2010 Posts: 21
|
Posted: Wed Jun 30, 2010 5:50 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jun 30, 2010 10:58 pm Post subject: |
|
|
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 |
|
|
|