Hello
I am trying to import data from an excel file but the spreadsheet name is causing problem. If I use 'Sheet1' as the name of the spreadsheet from which I want data, then it works fine but I want to change the name of the spreadsheet to the name which has spaces like 'PROJECT SHEET'. Please guide
Please help me.
I am trying to import data from an excel file but the spreadsheet name is causing problem. If I use 'Sheet1' as the name of the spreadsheet from which I want data, then it works fine but I want to change the name of the spreadsheet to the name which has spaces like 'PROJECT SHEET'. Please guide
Code:
Dim ExcelFile As String = "C:\ProjectFile.xlsx"
Dim myDatabasePath as string = "C:\ProjectsDatabase.mdb"
Dim excelConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFile + ";Extended Properties=""Excel 12.0 Xml;HRD=NO"""
Dim excelConnection As New OleDbConnection(excelConnectionString)
excelConnection.Open()
Dim strSQL As String
strSQL = "SELECT * INTO [MS Access;Database=" + myDatabasePath + "].tblttt " & _
"FROM (PROJECT SHEET$B1:E6)" '''<==== 'Problem'
Dim cmd1 As New OleDbCommand(strSQL, excelConnection)
cmd1.ExecuteNonQuery()
cmd1.Dispose()
Comment