I am creating a web application that imports excel files into a database. What occurs is that i have several excel files that I need to import from excel into a database. These files could be excel 97-2003 or excel 2007/2010. I have it determine which filetype it is and use the particular connection. This is how my code looks.
Before the above process happens I am using softartisan excel writer to add a range name cause I am using the range name to select the data and adding [ and ] in the column names in case the column names are not valid database column name format. The issue is that when I try to import the file that is excel 97-2003 it gives me the microsoft jet database engine could not find 'RangeName' and please make sure that the path and filename is correct. When I try this with excel 2007/2010 it imports the file and have no issues. I have checked the filepath and it is directing to the proper file. What could be the issue that is occurring here?
Code:
Dim strconn As String
If fileextesnison = ".xlsx" Then
strconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath +
";Extended Properties=""Excel 12.0 Xml;"";"
ELSE
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath+
";Extended Properties=""Excel 8.0;"";"
End if
Dim strSQL as string = "SELECT * FROM RangeName"
Dim olConn As New OleDbConnection(strconn)
Dim oadapter As OleDbDataAdapter
olConn.Open()
Dim od As New OleDbCommand(strSQL, olConn)
oadapter.selectcommand = od
Dim oData as dataset
oadapter.fill(odata, "Data")
olConn.Close()
Before the above process happens I am using softartisan excel writer to add a range name cause I am using the range name to select the data and adding [ and ] in the column names in case the column names are not valid database column name format. The issue is that when I try to import the file that is excel 97-2003 it gives me the microsoft jet database engine could not find 'RangeName' and please make sure that the path and filename is correct. When I try this with excel 2007/2010 it imports the file and have no issues. I have checked the filepath and it is directing to the proper file. What could be the issue that is occurring here?
Last edited: