Update on datatable

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<div id="x_post_message_4200035
I am not sure if this is the right forum to ask this question, if not I am very sorry. Ok I have a winform using Visual Studio 2010 and visual basic with a dataset and at the top are details from one table and in the middle a datagridview
of another table(compequip). In the datagridview it has two fields Component# (PK) and Equipment# (PK) The table is keyed on both fields to allow the user to insert multiple equipment#s for each component#. I also want it to display three fields from another
table - equipment table - description, Type and Department - these fields already have
http://www.vbforums.com/showthread.php?p=4200743#" id="x_itxthook0 " style="border-bottom:darkgreen 0.07em solid; padding-bottom:1px; background-color:transparent; color:darkgreen; font-size:100%; font-weight:normal; text-decoration:underline
<span id="x_itxthook0w0" style="background:none transparent scroll repeat 0% 0%; color:darkgreen data so it would be read-only - just to display the information about the equipment#s that are in the other table. I have made my join query to grab
those fields when I fill the compequip datatable. How can I do that and still allow the user to save the other two fields in the datagridview? I have attachd all 5 fields in the datagridview but when I run my save I get an error that Update is
not a member of MaintenanceTracker.SpartsDataSetTableAdapters.compequipTableAdapter.

Here is my save code:
Private Function Save() As Boolean
Dim saved as Boolean = False
If Me.SpartsDataSet.HasChanges Then
Try
Dim spartsUpdates() As DataRow = Me.SpartsDataSet.sparts.Select("","", DataViewRowState.Added or DataViewRowState.ModifiedCurrent)
Dim compequipUpdates() As DataRow = Me.SpartsDataSet.compequip.Select("","", DataViewRowState.Added or DataViewRowState.ModifiedCurrent)
Me.SpartsTableAdapter.Update(spartsUpdates)
Me.CompequipTableAdapter.Update(compequipUpdates)
Dim spartsDeletes() As DataRow = Me.SpartsDataSet.sparts.Select("","", DataViewRowState.Deleted)
Dim compequipDeletes() As DataRow = Me.SpartsDataSet.compequip.Select("","" DataViewRowState.Deleted)
Me.SpartsTableAdapter.Update(spartsDeletes)
Me.CompequipTableAdapter.Update(compequipDeletes)
saved = True
Catch ex As Exception
msgBox(ex.ToString)
End Try
End If
Return saved
End Function
I hope that makes sense. Thanks for all your help.<br/>
<br/>
Stacy


View the full article
 
Back
Top