更新:我几乎完成了我的代码,我正在尝试导出我的所有Excel工作表以使用VB.net进行访问。
到目前为止,在代码下方,创建新的访问文件,并只导入一个工作表。我想导入所有要访问的工作表。如果字段名称中有任何重复项,我想更新数据字段,或者创建新字段。
这是我的代码。
Dim _filename As String = "C:\Users\Admin\Desktop\test.xls"
Dim dbname As String = "D:\Book.mdb"
If File.Exists("D:\Book.mdb") Then
File.Delete("D:\Book.mdb")
End If
Dim cat As Catalog = New Catalog()
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\Book.mdb;" & _
"Jet OLEDB:Engine Type=5")
cat = Nothing
Dim _conn As String
_conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & _filename & ";" & "Extended Properties=Excel 8.0;"
Dim _connection As New OleDbConnection(_conn)
Dim _command As New OleDbCommand()
_command.Connection = _connection
_command.CommandText = "SELECT * INTO [MS Access;Database=D:\Book.mdb].[Sheet1] FROM [Sheet1$]"
_connection.Open()
_command.ExecuteNonQuery()
_connection.Close()
MessageBox.Show("The import is complete!")
任何建议