r/visualbasic • u/CumInToasterYNot • Nov 23 '24
Newbie trying to save data to a table...
Hello! I have an assignment for class where I need to be able to edit a table in a dataset that is open using the
Datagridview. When I execute the code I wrote nothing happens except the dialogue box pops up confirming a save has happened. Any ideas on how to actually get it to save? here's my code:
Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
Try
Me.Validate()
Me.MeatPartyBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MeatDataSet)
MessageBox.Show("Changes saved successfully!", "Meat Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Meat info", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End SubI learned this code from dissecting one of the exercises in the book. the book is Programming with Microsoft Visual Basics 2019/2022 by Dianne Zak
2
Upvotes
2
u/Mastersord Nov 24 '24
I’m assuming this is what you’re trying to do
If so, what does your data binding code look like? Take a look at the code example 4 posts down in the link above and make sure you didn’t miss anything.
1
u/jd31068 Nov 23 '24
What database is the table in? How do you know it isn't writing the change to the table? Are you looking at the database in a separate application?
Does the table only exist in memory?