[This all happens in VB.net]
I have 2 forms.
Form 1 has a grid which is bound to a dataset and shows a couple of rows during run-time. It has the OleDbConnection, OleDbDataAdapter and DataSet icons at the bottom of the VB.net designer.
Form 2 has all the controls to view all the informtion of a single row of the dataset. It ALSO has IT'S OWN OleDbConnection, OleDbDataAdapter and DataSet icons at the bottom of the VB.net designer.
What I need to do:
When I double-click on one of the rows in the grid of Form 1, the row_id is passed on to Form 2 and Form 2 pops up with all the field info of that row inserted into dropdown and textboxes. So far, so good. Now, I can change the field info and hit a save button on Form 2 to update the dataset and CLOSE Form 2... which also works fine... But here is where the problem comes up.
1. How do I update my grid on Form 1 to reflect the changes I have made? 2. Where do I put this command?
Should I be working with 2 seperate connections, data adapters and datasets? 1 set on each form? Probably not... But I don't know of any better solution. Any help will be much appreciated.
It's Ok to have two forms. Reusing the connection object is not going to buy you anything, as adapters close the connection anyway as soon as the dataset has finished loading.
What you need to do is reload the dataset with the updated information, just by issuing a adapter.Fill(dataset) call again, just like I assume you're doing when the form is loaded the first time. You don't need a new command for refreshing. Just out of curiosity, are you using a database other than MSDE or SQL Server and that's why you use OleDb data provider components instead of the SqlClient ones?
This was first published in October 2004