datagrid中增加和修改记录问题
Public myda As SqlClient.SqlDataAdapter
Public dset As New DataSet
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlstr As String
sqlstr = "select * from t_user"
myda = New SqlClient.SqlDataAdapter(sqlstr, mycon)
myda.Fill(dset, "用户表")
DataGrid1.DataSource = dset.Tables("用户表")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
myda.Update(dset.GetChanges)
dset.AcceptChanges()
End Sub
我想在datagrid1修改一条记录
代码执行button1_click事件可以正常执行
但是执行button2_clikc就有错误
不知道我这两句代码有什么问题,麻烦大家帮看一下
myda.Update(dset.GetChanges)
dset.AcceptChanges()