Here is one

  • Thread starter Thread starter Newbie!
  • Start date Start date
N

Newbie!

Hiya Group,

Sorry to be such a pain but .......... I have a little problem,

On my Form I have a ListBox, with 5 Options, Each Option relates to a Table
in My database, I also have Add, Update, and Delete Buttons, with one
DataGrid.

My question is how do i populate the datagrid from the Listbox and get the
Add, Remove, and Update Buttons working for each Table?

Any Code of URL`s?

Many Thanks
Si
 
Load a DataSet dsMain with each of the five tables from the Database. Then,
when the user clicks on an item in the listbox, bind the grid to the
datatable which corresponds to the listbox's value

So, if I click on Table2 in the Listbox,
myDataGrid.DataSource = myDataSet.Tables["Table2"]; //or you could use the
numerical index.

The grid will allow the user to create/delete/update records, so you can
wait until the user changes the item in the ListBox, or wait until the form
is about to close or whatever and if myDataSet.HasChanges;
myDataAdapter.Update(myDataSet, "Table1")//there's a lot of flexibility
about when you submit your changes and freshness of data and how urgent
updates are to everyone else will dictate how often you want to submit
updates. Regardless, just submit an update for the tables that have
changed. You can either track this setting a flag so you know what table
you are on, or just walk through the Tables collection and fire an update
for each table...


If you are using anything more than a grid for updating though, you'll
probably want to take a look at the BindingManagerBase/BindingContext and
add the databindings individually to each control.
HTH,

Bill
 
Back
Top