Dim strConn As String = "driver={microsoft access driver (*.mdb)};uid=admin;pwd=;dbq=" &
Application.StartupPath & "\ACCESS.MDB"
Dim cn As New OdbcConnection(strConn)
cn.Open()
Dim da As New OdbcDataAdapter("Select * From 表名", cn)
Dim ds As New DataSet
da.Fill(ds, "表名")
Dim cmdBuilder As New OdbcCommandBuilder(da)
da.InsertCommand = cmdBuilder.GetInsertCommand
With ds.Tables("表名")
For i = 0 to DataGridView1.Rows.Count - 1
Dim dr As DataRow = .NewRow
dr("列名1") = DataGridView1中的值
.
.
.
dr("列名n") = DataGridView1中的值
.Rows.Add(dr)
next
End With
da.Update(ds.Tables("表名"))
cn.Close()
如果不明白继续问