Retriving data from excel sheet into an asp page

Reply

Join Date: Jun 2005
Posts: 4
Reputation: Pallavivt is an unknown quantity at this point 
Solved Threads: 0
Pallavivt Pallavivt is offline Offline
Newbie Poster

Retriving data from excel sheet into an asp page

 
0
  #1
Jun 23rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #2
Jun 23rd, 2005
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!


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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: Pallavivt is an unknown quantity at this point 
Solved Threads: 0
Pallavivt Pallavivt is offline Offline
Newbie Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #3
Jun 24th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: Pallavivt is an unknown quantity at this point 
Solved Threads: 0
Pallavivt Pallavivt is offline Offline
Newbie Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #4
Jun 24th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #5
Jun 24th, 2005
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).



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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: Pallavivt is an unknown quantity at this point 
Solved Threads: 0
Pallavivt Pallavivt is offline Offline
Newbie Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #6
Jun 24th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #7
Jul 1st, 2005
See here

LINK

Google / MSDN is our Friend!

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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1
Reputation: ManjuPeter is an unknown quantity at this point 
Solved Threads: 0
ManjuPeter ManjuPeter is offline Offline
Newbie Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #8
Aug 18th, 2005
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

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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 107
Reputation: madmital is an unknown quantity at this point 
Solved Threads: 3
madmital madmital is offline Offline
Junior Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #9
Aug 18th, 2005
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 1
Reputation: AlThomson is an unknown quantity at this point 
Solved Threads: 0
AlThomson AlThomson is offline Offline
Newbie Poster

Re: Retriving data from excel sheet into an asp page

 
0
  #10
Oct 9th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC