Adding new row

xpertwinner

Member
Joined
Dec 26, 2008
Messages
24
Programming Experience
Beginner
I open a new form for the user to add a new record to the datatable.
I am using the code:

Dim row As RestricoesDataset.ComparaçãoRow = RestricoesDataset.Comparação.NewComparaçãoRow()
row.Mod1 = Mod1ComboBox.SelectedValue
row.Mod2 = Mod2ComboBox.SelectedValue
row.Comparação = ComparaçãoComboBox.SelectedValue
RestricoesDataset.Comparação.AddComparaçãoRow(row)
Me.Close()

When I press the add new row button, this code is executed, and I can see the new row in the datagridview. However, if I close and reopen the form, the row isnt there anymore. Am i not saving as I should?

I have other question. I read in a tutorial that I should dispose the datagridviews on form closing. However, when I reopen the form they aren't there anymore. How can I counter this effect?

Thanks in advance.
 
You're not saving at all. That code only adds the row to your DataTable, which is your app's local cache of data. In order to save the changes that you make to that data back to the database you have to call Update on your TableAdapter and pass the DataTable as an argument.
 

Latest posts

Back
Top