从 excel 中导入数据到 access,运行正常,但数据库文件中数据没变啊
Private Sub Command3_Click()Dim i As Integer
Dim s As Integer
Dim rst As New ADODB.Recordset
Dim rs As New ADODB.Recordset
If fn1count <= fncount Then
rst.Open "select * from [" & & "]", cn, adOpenDynamic
rs.Open "select * from " & Combo1.Text & "", conn, adOpenDynamic, adLockBatchOptimistic
rs.MoveLast
i = rst.RecordCount
Do While Not rst.EOF
On Error Resume Next
rs.AddNew
For s = 0 To fn1count - 1
rs.Fields(s).Value = rst.Fields(s).Value
Next s
rs.MoveNext
rst.MoveNext
i = i - 1
If i = 0 Then
faccess.Caption = "数据导入完毕!"
rs.Update
MsgBox "已经成功导入" & rst.RecordCount & "条记录!", vbInformation, "温馨提示"
Else
faccess.Caption = "数据正在导入请稍候……"
End If
Loop
Else
MsgBox "Excel 表数据字段数大于Access表数据字段数!", vbInformation, "温馨提示"
End If
Set rs = Nothing
Set rst = Nothing
rs.Close
rst.Close
End Sub