K
KPS
Hello,
I have tried to read Excel spreadsheet through ADO. I used the sample code
provided by msdn.I don't know what the **** is the matter with the code
cause I can't read the Excel. I tried similar system with Access and it
works fine. Here is the error and the sample code.
Error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not
find the object 'ASPTOC'. Make sure the object exists and that you spell its
name and the path name correctly.
/ASPTOC.asp, line 21
Code:
<%@Language=VBScript %>
<html>
<head>
<title> Displaying An Excel Spreadsheet in an Web Page </title>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<h1>ASP Table of Contents</h1>
<%
'Creates an instance of an Active Server Component
Set oConn = Server.CreateObject("ADODB.Connection")
'Connects to the Excel driver and the Excel spreadsheet
'in the directory where the spreadsheet was saved
strProvider = "Driver={Microsoft Excel Driver (*.xls)};
DBQ=C:\Inetpub\wwwroot\Testi_site\ASPTOC.xls;"
'Opens the connection to the data store
oConn.Open strProvider
'Selects the records from the Excel spreadsheet
strCmd = "SELECT * from `ASPTOC`"
Set oRS = Server.CreateObject("ADODB.Recordset")
'Opens the recordset
oRS.Open strCmd, oConn
'Prints the cells and rows in the table
Response.Write "<table border=1><tr><td>"
'Gets records in spreadsheet as a string and prints them in the table
Response.Write oRS.GetString (, , "</tr><td>", "</td></tr><tr><td>",
NBSPACE)
%>
</body>
</html>
It looks like ODBC error but I did the ODBC like instructed. I also
installed the .net framework and latest MDAC to the server. The sample code
instructions say that u should use Excel 98 or 2000. I'm using Excel 2002.
Can this be the problem?? I think i've tried everything but can't figure
this out. Can anyone please help me???
Thanks!
KS
I have tried to read Excel spreadsheet through ADO. I used the sample code
provided by msdn.I don't know what the **** is the matter with the code
cause I can't read the Excel. I tried similar system with Access and it
works fine. Here is the error and the sample code.
Error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not
find the object 'ASPTOC'. Make sure the object exists and that you spell its
name and the path name correctly.
/ASPTOC.asp, line 21
Code:
<%@Language=VBScript %>
<html>
<head>
<title> Displaying An Excel Spreadsheet in an Web Page </title>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<h1>ASP Table of Contents</h1>
<%
'Creates an instance of an Active Server Component
Set oConn = Server.CreateObject("ADODB.Connection")
'Connects to the Excel driver and the Excel spreadsheet
'in the directory where the spreadsheet was saved
strProvider = "Driver={Microsoft Excel Driver (*.xls)};
DBQ=C:\Inetpub\wwwroot\Testi_site\ASPTOC.xls;"
'Opens the connection to the data store
oConn.Open strProvider
'Selects the records from the Excel spreadsheet
strCmd = "SELECT * from `ASPTOC`"
Set oRS = Server.CreateObject("ADODB.Recordset")
'Opens the recordset
oRS.Open strCmd, oConn
'Prints the cells and rows in the table
Response.Write "<table border=1><tr><td>"
'Gets records in spreadsheet as a string and prints them in the table
Response.Write oRS.GetString (, , "</tr><td>", "</td></tr><tr><td>",
NBSPACE)
%>
</body>
</html>
It looks like ODBC error but I did the ODBC like instructed. I also
installed the .net framework and latest MDAC to the server. The sample code
instructions say that u should use Excel 98 or 2000. I'm using Excel 2002.
Can this be the problem?? I think i've tried everything but can't figure
this out. Can anyone please help me???
Thanks!
KS