2016-06-08 40 views
0

我已通过管理器将Oracle连接设置为DatagridView。线是这样的:VB.NET - 将数据格式视图中的更改保存到数据库

Me.UsersTableAdapter.Fill(Me.MyDataSet._Users) 

现在我想保存在数据格式视图中的所有更改为数据库。试过这个,但不工作:

Me.UsersTableAdapter.Update(Me.MyDataSet._Users) 

我在这里错过了什么?

+0

你得到了什么错误? – Fabio

+0

@Fabio,没有错误,只是没有任何反应。 – LuckyLuke82

回答

0

解决。正确的synthax是:

Try 
    Me.Validate() 
    Me.UsersBindingSource.EndEdit() 
    Me.UsersTableAdapter.Update(Me.MyDataSet._Users) 
    MsgBox("Update successful") 

Catch ex As Exception 
    MsgBox("Update failed") 
End Try 

@ the scion,thanks!

1

1.你可能错过了validate()endEdit()

Try 
    Me.Validate() 
    Me.UsersBindingSource.EndEdit() 
    Me.UsersTableAdapter.Update(Me.MyDataSet._Users) 
    MsgBox("Update successful") 

Catch ex As Exception 
    MsgBox("Update failed") 
End Try 
  • 你有表主键?
  • 更新

    解决我目前的代码 -

    Me.UsersBindingSource.EndEdit() 
    

    link

    +0

    感谢您的链接。,它现在可以工作。但是你犯了一个小错误,看到我的答案(EndEdit需要BindingSource,而不是TableAdapter)。 – LuckyLuke82

    相关问题