意图:点击button1按钮更新datagrid中修改的数据
Dim mydataset As New DataSet
Private Sub cbbm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=0101;Data Source=" + CurDir() + "\cgMain.MDB;"
Dim myconn As OleDbConnection = New OleDbConnection
myconn.ConnectionString = strcon
Dim strcom As String = "select 部门 from 承办部门"
myconn.Open()
Dim mycommand As New OleDbDataAdapter(strcom, myconn)
mycommand.Fill(mydataset, "承办部门")
myconn.Close()
DataGrid1.DataSource = mydataset.Tables("承办部门")
End Sub
意图:点击button1按钮更新datagrid中修改的数据
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mydataset.GetChanges()
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=0101;Data Source=" + CurDir() + "\cgMain.MDB;"
Dim myconn As OleDbConnection = New OleDbConnection
myconn.ConnectionString = strcon
Dim strcom As String = "select 部门 from 承办部门"
myconn.Open()
Dim mycommand As New OleDbDataAdapter(strcom, myconn)
mycommand.Update(mydataset.Tables("承办部门")) ’这里提示出错!!!!
mydataset.AcceptChanges()
myconn.Close()
Close()
End Sub
运行结果,数据成功在datagrid中显示出来,就是更新数据库的时候出错,求救!!!
[此贴子已经被作者于2006-1-19 10:17:25编辑过]