我有一个将 Excel 文件导入 MS Access 数据库表的模块。我得到:MS Access 数据库引擎找不到对象“REPORTCONFIG”。表 REPORTCONFIG 确实存在,并且它被代码“拾取”,因为就在我导入 excel 之前,我首先将表清空(工作正常)。我已确保我的 excel 中的选项卡与表格名称相同。(报告配置)
这是我的模块:
Dim MyExcelFileDialogBox As New OpenFileDialog()
If MyExcelFileDialogBox.ShowDialog = DialogResult.OK Then
MyExcelFullFileName = MyExcelFileDialogBox.FileName
MyExcelFile = Dir(MyExcelFileDialogBox.FileName)
MyExcelFilePath = Path.GetDirectoryName(MyExcelFileDialogBox.FileName)
ModuleConnection.AccessConnect()
ModuleTables.DeleteTableContent(MyTableName)
Dim MyExcelInsertSQL As String = "INSERT INTO [" & MyTableName & "] SELECT * FROM [Excel 12.0;HDR=YES;DATABASE=" & MyExcelFullFileName & "].[" & MyTableName & "];"
Dim MyCommand As OleDbCommand = New OleDbCommand(MyExcelInsertSQL, MyAccessConnection)
Try
MyCommand.ExecuteNonQuery()
MyCommand.Dispose()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
MyAccessConnection.Close()
End If
任何帮助表示赞赏。