944,126 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 75951
  • ASP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 23rd, 2005
0

Retriving data from excel sheet into an asp page

Expand Post »
Hello

I am new in ASP

what i want is to retrive the records from excel sheet and show them on an asp page in tabular format

i tried to do it with ADODB.Connection
conn.Provider = "MSDASQL"
conn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" & Server.mappath("/"& excelfilename) &";ReadOnly= false ; UID=admin;"

the connection get opened successfully but no the main problem is to fetch the data into recorset. the error comes into query

pls do tell me what should b the query for fetching the record

i also tried the "Microsoft.Jet.OLEDB.4.0" provider but it gives an error in connection as "cant find installable isam"

thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pallavivt is offline Offline
4 posts
since Jun 2005
Jun 23rd, 2005
0

Re: Retriving data from excel sheet into an asp page

Ok,

Well since you provided no information about what columns are in your table (excel spreadsheet) and what data you want from that table (i.e. DDL (Data Definition Language)) providing help on a query will be rather hard.

So until you provide that information, help will be difficult to get.

The provider "Microsoft.Jet.OLEDB.4.0" is for Access not Excel, so your first choice was correct.

Provide the query you have tried!

Do you know how to creat a recordset?


Example:

Table (excel spreadsheet)
Col A || Col B

Dim objConn
Set objConn = Server.CreateObject ("ADODB.Connection")
objConn.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" & Server.mappath("/"& excelfilename) &";ReadOnly= false ; UID=admin;"

Dim strSQL
strSQL = "SELECT Col A FROM excelfilename"
Dim objRS
Set objRS = Server.CreateObject ("ADODB.RecordSet")
objRS.Open strSQL, objConn
...
...
'  Your code to display this recordset
...
...
'  Memroy/garbage clean up.... in the proper order
objRS.Close
Set objRS = Nothing
objConn.Close
Set objClose = Nothing

...
Hope this helps, but please provide further information if you want more detailed help!


Quote originally posted by Pallavivt ...
Hello

I am new in ASP

what i want is to retrive the records from excel sheet and show them on an asp page in tabular format

i tried to do it with ADODB.Connection
conn.Provider = "MSDASQL"
conn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" & Server.mappath("/"& excelfilename) &";ReadOnly= false ; UID=admin;"

the connection get opened successfully but no the main problem is to fetch the data into recorset. the error comes into query

pls do tell me what should b the query for fetching the record

i also tried the "Microsoft.Jet.OLEDB.4.0" provider but it gives an error in connection as "cant find installable isam"

thanks
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Jun 24th, 2005
0

Re: Retriving data from excel sheet into an asp page

hello
thanks

i want to select all the columns from the excelfile say abc.xls which contains sheet name abc

i tried the following queries and got error

excelfilename = "abc.xls"
"select * from " & excelfilename

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'xls'. Make sure the object exists and that you spell its name and the path name correctly.


select * from [abc.xls$]

The Microsoft Jet database engine could not find the object 'abc.xls$'. Make sure the object exists and that you spell its name and the path name correctly.

"SELECT ColA,ColB,ColC FROM abc"
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'abc' Make sure the object exists and that you spell its name and the path name correctly.


pls reply soon

thanks

pallavi
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pallavivt is offline Offline
4 posts
since Jun 2005
Jun 24th, 2005
0

Re: Retriving data from excel sheet into an asp page

now it is giving me another erroer as
Microsoft OLE DB Provider for ODBC Drivers (0x80040E09)
[Microsoft][ODBC Excel Driver] Cannot update. Database or object is read-only.

i tried with
;Readonly = false; and also ;Readonly= true;
but still it is giving the same error
psl tell me how to do solve this error
also the file on the server is not readonly
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pallavivt is offline Offline
4 posts
since Jun 2005
Jun 24th, 2005
0

Re: Retriving data from excel sheet into an asp page

I am guessing you have it open already. Don't have the Excel Spreadsheet open when trying to connect to it... but I am just guessing.

Here is what you do for the select statement.

Select * FROM [Sheet1$]

Where the [Sheet1$] represent the Worksheet that is in the workbook (the XLS) you are accessing.

Hope that helps .... and thanks for clarifying your request (you will always get a faster response that way).



Quote originally posted by Pallavivt ...
now it is giving me another erroer as
Microsoft OLE DB Provider for ODBC Drivers (0x80040E09)
[Microsoft][ODBC Excel Driver] Cannot update. Database or object is read-only.

i tried with
;Readonly = false; and also ;Readonly= true;
but still it is giving the same error
psl tell me how to do solve this error
also the file on the server is not readonly
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Jun 24th, 2005
0

Re: Retriving data from excel sheet into an asp page

even if i stype the sheet name teill it gives me error

the excel filename and the name of the sheet are the same
strSQL = "SELECT * FROM [DIV$]"

Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'DIV$'. Make sure the object exists and that you spell its name and the path name correctly.

i tried doing with "Select * from DIV.DIV" & excelfilename

Microsoft OLE DB Provider for ODBC Drivers (0x80040E09)
[Microsoft][ODBC Excel Driver] Cannot update. Database or object is read-only.

if the query is "Select * from DIV.DIV"

Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'DIV'. Make sure the object exists and that you spell its name and the path name correctly.

even "Select * from DIV.[DIV$]" gives the same error
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pallavivt is offline Offline
4 posts
since Jun 2005
Jul 1st, 2005
0

Re: Retriving data from excel sheet into an asp page

See here

LINK

Google / MSDN is our Friend!

Quote originally posted by Pallavivt ...
even if i stype the sheet name teill it gives me error

the excel filename and the name of the sheet are the same
strSQL = "SELECT * FROM [DIV$]"

Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'DIV$'. Make sure the object exists and that you spell its name and the path name correctly.

i tried doing with "Select * from DIV.DIV" & excelfilename

Microsoft OLE DB Provider for ODBC Drivers (0x80040E09)
[Microsoft][ODBC Excel Driver] Cannot update. Database or object is read-only.

if the query is "Select * from DIV.DIV"

Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'DIV'. Make sure the object exists and that you spell its name and the path name correctly.

even "Select * from DIV.[DIV$]" gives the same error
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Aug 18th, 2005
0

Re: Retriving data from excel sheet into an asp page

Hi Pallavi,

If you have the solution for the "The Microsoft Jet database engine could not find the object 'abc.xls$'. Make sure the object exists and that you spell its name and the path name correctly." error, Do let me know.

I am trying to access excel similarly and update my database. I can open the connection but my record set is not getting opened . My excel file has a worksheet named Sheet1 and I am using "select * from [Sheet1$]" as the query string.

please help

Quote originally posted by Pallavivt ...
hello
thanks

i want to select all the columns from the excelfile say abc.xls which contains sheet name abc

i tried the following queries and got error

excelfilename = "abc.xls"
"select * from " & excelfilename

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'xls'. Make sure the object exists and that you spell its name and the path name correctly.


select * from [abc.xls$]

The Microsoft Jet database engine could not find the object 'abc.xls$'. Make sure the object exists and that you spell its name and the path name correctly.

"SELECT ColA,ColB,ColC FROM abc"
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E37)
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'abc' Make sure the object exists and that you spell its name and the path name correctly.


pls reply soon

thanks

pallavi
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ManjuPeter is offline Offline
1 posts
since Aug 2005
Aug 18th, 2005
0

Re: Retriving data from excel sheet into an asp page

Reputation Points: 10
Solved Threads: 5
Junior Poster
madmital is offline Offline
119 posts
since Jun 2005
Oct 9th, 2005
0

Re: Retriving data from excel sheet into an asp page

Hi guys

I read this post when I got stuck connecting to excel.

I now have a method that works for me. I'm not entirely sure of the pros and cons of using this method.


'Dims
Dim cn
Dim rs
Dim strQuery
'---------
set cn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("adodb.recordset")


With cn

.Provider = "MSDASQL"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" & "DBQ=C:\inetpub\wwwroot\server\adotest.xls; ReadOnly=False;"
.Open

End With

'If not using a named range, replace myrange1 with [sheet1$]
strQuery = "SELECT * FROM myRange1"
rs.Open strquery, cn

'Check for records
rs.MoveFirst
if rs.BOF = true and rs.EOF = true then
'no records
response.Write "Error:: Products spreadsheet is empty!"
else
'Records Exist
'Loop through records printing out the fields
while not rs.EOF
response.Write rs.Fields(0) & " " & rs.Fields(1) & " " & rs.Fields(2) & "<BR><BR>"
rs.MoveNext
wend
end if



'Cleanup
rs.close
cn.Close
set cn = nothing
set rs = nothing
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AlThomson is offline Offline
1 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Upload Images Using Progress Bar In classic ASP
Next Thread in ASP Forum Timeline: ASP form question.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC