|
-
May 5th, 2013, 10:17 AM
#1
Thread Starter
New Member
Save changes to Dataset from different TableAdapters
Hello everyone,
Can someone please tell me why when i press the button to save the changes on several textboxe´s that i have from diferente tables, if i press the button it only save the changes from the first BindingContext, then i need to click on the other textbox and if the cursor is blinking there then i can press the save button again and then gets the changes again from that table and it works.
I would like to press the "save" button and save all the textbox´s at once.
The code that i have is this:
Code:
Public Class frmPNTStockList
Private Sub frmAllPNTStockList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.HIGH_VISIBILITY_VEST' table. You can move, or remove it, as needed.
Me.HIGH_VISIBILITY_VESTTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.HIGH_VISIBILITY_VEST)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.PILOT_WING' table. You can move, or remove it, as needed.
Me.PILOT_WINGTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.PILOT_WING)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.TIE_MAN' table. You can move, or remove it, as needed.
Me.TIE_MANTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.TIE_MAN)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.STRIPES_FO' table. You can move, or remove it, as needed.
Me.STRIPES_FOTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.STRIPES_FO)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.STRIPES_COM' table. You can move, or remove it, as needed.
Me.STRIPES_COMTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.STRIPES_COM)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.BLUE_BELT_MEN' table. You can move, or remove it, as needed.
Me.BLUE_BELT_MENTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.BLUE_BELT_MEN)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.OVERCOAT_MAN' table. You can move, or remove it, as needed.
Me.OVERCOAT_MANTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.OVERCOAT_MAN)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.WHITE_SHIRT_LONG_SLEEVE' table. You can move, or remove it, as needed.
Me.WHITE_SHIRT_LONG_SLEEVETableAdapter.Fill(Me.Uniforms_SoftwareDataSet.WHITE_SHIRT_LONG_SLEEVE)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.WHITE_SHIRT_SHORT_SLEEVE' table. You can move, or remove it, as needed.
Me.WHITE_SHIRT_SHORT_SLEEVETableAdapter.Fill(Me.Uniforms_SoftwareDataSet.WHITE_SHIRT_SHORT_SLEEVE)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.TROUSERS_DARK_BLUE_MAN' table. You can move, or remove it, as needed.
Me.TROUSERS_DARK_BLUE_MANTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.TROUSERS_DARK_BLUE_MAN)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.BLAZER_DARK_BLUE_FO' table. You can move, or remove it, as needed.
Me.BLAZER_DARK_BLUE_FOTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.BLAZER_DARK_BLUE_FO)
'TODO: This line of code loads data into the 'Uniforms_SoftwareDataSet.BLAZER_DARK_BLUE_COM' table. You can move, or remove it, as needed.
Me.BLAZER_DARK_BLUE_COMTableAdapter.Fill(Me.Uniforms_SoftwareDataSet.BLAZER_DARK_BLUE_COM)
End Sub
Private Sub btnPNTSave_Click(sender As Object, e As EventArgs) Handles btnPNTStockListSave.Click
Save_Records()
End Sub
Private Sub Save_Records()
With Me.BindingContext(Me.Uniforms_SoftwareDataSet, "BLAZER_DARK_BLUE_COM")
.EndCurrentEdit()
If Uniforms_SoftwareDataSet.HasChanges Then
Try
If MsgBox("Record has changer!" & vbCrLf & "Save changes?", MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
Me.BLAZER_DARK_BLUE_COMTableAdapter.Update(Uniforms_SoftwareDataSet.GetChanges())
Uniforms_SoftwareDataSet.AcceptChanges()
Else
Uniforms_SoftwareDataSet.RejectChanges()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End With
With Me.BindingContext(Me.Uniforms_SoftwareDataSet, "BLAZER_DARK_BLUE_FO")
.EndCurrentEdit()
If Uniforms_SoftwareDataSet.HasChanges Then
Try
If MsgBox("Record has changer!" & vbCrLf & "Save changes?", MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
Me.BLAZER_DARK_BLUE_FOTableAdapter.Update(Uniforms_SoftwareDataSet.GetChanges())
Uniforms_SoftwareDataSet.AcceptChanges()
Else
Uniforms_SoftwareDataSet.RejectChanges()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End With
With Me.BindingContext(Me.Uniforms_SoftwareDataSet, "TROUSERS_DARK_BLUE_MAN")
.EndCurrentEdit()
If Uniforms_SoftwareDataSet.HasChanges Then
Try
If MsgBox("Record has changer!" & vbCrLf & "Save changes?", MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
Me.TROUSERS_DARK_BLUE_MANTableAdapter.Update(Uniforms_SoftwareDataSet.GetChanges())
Uniforms_SoftwareDataSet.AcceptChanges()
Else
Uniforms_SoftwareDataSet.RejectChanges()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End With
With Me.BindingContext(Me.Uniforms_SoftwareDataSet, "WHITE_SHIRT_SHORT_SLEEVE")
.EndCurrentEdit()
If Uniforms_SoftwareDataSet.HasChanges Then
Try
If MsgBox("Record has changer!" & vbCrLf & "Save changes?", MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
Me.WHITE_SHIRT_SHORT_SLEEVETableAdapter.Update(Uniforms_SoftwareDataSet.GetChanges())
Uniforms_SoftwareDataSet.AcceptChanges()
Else
Uniforms_SoftwareDataSet.RejectChanges()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End With
End Sub
End Class
Thank you.
Last edited by Blue_Wings; May 7th, 2013 at 01:49 PM.
-
May 5th, 2013, 03:24 PM
#2
Re: Save changes to Dataset from different TableAdapters
You have a different table for every item?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 5th, 2013, 04:54 PM
#3
Addicted Member
Re: Save changes to Dataset from different TableAdapters
That's like having a wallet for each cent.
-
May 7th, 2013, 01:51 PM
#4
Thread Starter
New Member
Re: Save changes to Dataset from different TableAdapters
I have this tables because in the case of the table BLUE_BELT_MEN, OVERCOAT_MAN, WHITE_SHIRT_LONG_SLEEVE, WHITE_SHIRT_SHORT_SLEEVE, TROUSERS_DARK_BLUE_MAN, BLAZER_DARK_BLUE_FO and BLAZER_DARK_BLUE_COM can have diferente sizes like: S, M, L, XL, XXL and XXXL.
The single items like HIGH_VISIBILITY_VEST, PILOT_WING, TIE_MAN, STRIPES_COM and STRIPES_FO you are right that could in in only in one table 
But about the problem to save all of the textbox at the same time, does anyone can help me?
Thanks
Last edited by Blue_Wings; May 7th, 2013 at 01:56 PM.
-
May 7th, 2013, 02:02 PM
#5
Re: Save changes to Dataset from different TableAdapters
Still doesn't make any sense! One table is more than sufficient.
But about the problem to save all of the textbox at the same time, does anyone can help me?
No, is the honest answer. You can only update the table that matches the binding. By multiplying the bindings/tables out of all proportion you've made it all but impossible to connect the tables with the changes in any kind of consistent way.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|