0
votes

I need to import an Excel file. I am using the following code to connect to the sheet:

Set objConn = Server.CreateObject ("ADODB.Connection")

objConn.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" & Server.mappath(C:\sample\abcd.xls) & ";ReadOnly= false ; UID=admin;"

On doing so, I am getting the following error:

Microsoft OLE DB Provider for ODBC Drivers error ''80004005''.

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

What is causing this error?

1
Server.mappath("C:\sample\abcd.xls") Quotes? - MC ND

1 Answers

1
votes

Instead of using the older ODBC drivers, try using the JET drivers (which I've done):

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(C:\sample\abcd.xls) & ";
Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"

Or, if your data access drivers are up to date you can use the newer ACE OLEDB drivers (which I've moved to):

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath(C:\sample\abcd.xls) & ";
Extended Properties=""Excel 12.0;HDR=YES"";"

See connectionstrings.com for other ways to connect.