1

I must be missing something really obvious but I have narrowed down the problem to the simplest possible repro case.

I am trying to debug an old Winforms 2.0 app that has no docs and was written, well a long time ago. I am using VS 2012.

I have a SQLCE 4.0 DB with 4 small tables in it. I created a DataSet by adding the DB to the DataSources window.

I then added a bindingSource and DataGridView to the form bound them together and pointed them at the DataSource and they added a strongly typed DataSet.

If I manually enter the data into the SDF using Server Explorer and then run the app I see all the data in the grid.

BUT if I enter data into the grid, one row or many it does not get committed to the DB.

If I do all this in code and don't use any of the autogenerated stuff I can get it to work but the existing app uses all the autogenerated stuff and I don't feel like going back and fixing 20+ grids by hand if this is the only pattern I can get to work.

I feel like I must be missing something really simple that writes are not getting through to the DB, but I can't find it.

Thx

4

1 回答 1

0

也许像这样..在VB中

当你有这个..

Private bindingSource1 As New BindingSource()
Private dataAdapter As New SqlDataAdapter()
Dim table As New DataTable()

这样做

Me.dataAdapter.Fill(table)
Me.bindingSource1.DataSource = table

然后用户在您的绑定源中进行了一些更改,然后不要忘记

Me.dataAdapter.Update(CType(Me.bindingSource1.DataSource, DataTable))
于 2013-06-09T16:06:19.520 回答