Datagrid Question ^_^

PoisonousFish

Member
Joined
Jan 24, 2009
Messages
8
Programming Experience
1-3
Okay, I have a datagrid that is bound to a table in a dataset. It works great.

Also when I add a row to the database like so it also works:
Me.GameTableTableAdapter.addrow(gameWon, CType(numGuesses, Byte), userName)

And this does commit to the database. However, I am trying to figure out how to get these changes to reflect in the dataset so that the new data added will show up in the grid so I don't have to refill the dataset like so:

Me.GameTableTableAdapter.FillByTop10(Me.GameDatabaseDataSet.GameTable)

Obiously this is inefficient. Again, thanks in advance.
 
If you want the data in the DataSet to change then you need to change the data in the DataSet and save form there rather than making changes to the database directly. Populate GameTable to start with and then edit the rows it contains, calling Update on the TableAdapter to save the changes.
 
Okay, I have a datagrid that is bound to a table in a dataset. It works great.

Also when I add a row to the database like so it also works:
Me.GameTableTableAdapter.addrow(gameWon, CType(numGuesses, Byte), userName)
I think you may be getting confused; TableAdapters don't contain AddRow as a method because a TA cannot be a container for data, so it doesnt make sense to call a method "Add" in this way

I see jmc has solved the problem.. I'd guess that the root cause of the confusion is:

TableAdapter.InsertRow = does a direct insert of data into the db
DataTable.AddRow = adds data to a datatable, which a tableadapter will later persist to DB during a call to Update() (which is also stupidly named given that it isnt necessarily an SQL UPDATE command that is used)
 
It's the age old problem of making something powerful and flexible enough to satisfy the pros while keeping it simple enough so as not to put off the noobs.. Very hard balance to strike. Keep with it an you'll be glad of the intricacies, honest!
 

Latest posts

Back
Top