0

In my C# winforms project I have a DataGridView which is displaying a View of two SQL tables. Is there a workaround for Updating the View from the DataGridView.

Using a Save button on my form,
At first I assumed I could update the View like this:

this.DataSet.EndInit();
this.ViewTableAdapter.Update(this.DataSet.View);

Did not work so I tried updating the tables separately and still was not able to update:

this.DataSet.EndInit();
this.TableOneTableAdapter.Update(this.DataSet.TableOne);
this.TableTwoTableAdapter.Update(this.DataSet.TableTwo);

I have another form where a DataGridView is displaying just one Table and using the following works fine when Updating:

this.DataSet.EndInit();
this.TableTableAdapter.Update(this.DataSet.Table);
2
Contributors
1
Reply
4
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

No, if you want to update view, you will have to re-populate dgv.
You can do it on 2 ways:
1. create dataTable and bind it to the dataSource of dgv
2. crete dataTable and populate dgv manually (column by column, row by row)

The best way of populating dgv is to fill dataTable with sql adapter (in sql query), and then use these data in dataTable.

Hope it helps,
happy coding
If you need any asistance, let me know, and please specify exactly what you need and if possible give us some of your code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.