If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > file system object

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-20-06, 05:15
ymadhuri ymadhuri is offline
Registered User
 
Join Date: Nov 2005
Posts: 6
file system object

Hi Guys,
I am trying to open an excel sheet on an ASP page using the using the following code given below. but it looks like on some machines the File System object is getting created and on some machines not. On some systems the excel sheet opens and on other it doesn't open, instead it throws a http 500 error. Can you please tell me why this is happening.
Regards,
Madhuri

SET rsQuery = objconn.execute(strSqlQuery1)
if not rsQuery.EOF then
set fso = createobject("scripting.filesystemobject")
' create the text (xls) file to the server adding the -mmddyyyy after the g_title value
Set act = fso.CreateTextFile(server.mappath(""&g_filename & "-"& month(date())& day(date())& year(date()) &".xls"), true)

strLine="" 'Initialize the variable for storing the filednames

For each x in rsQuery.fields
strLine= strLine & x.name & chr(9)
Next

act.writeline strLine

Do while Not rsQuery.EOF
strLine=""
for each x in rsQuery.Fields
strLine= strLine & x.value & chr(9)
next
act.writeline strLine
rsQuery.MoveNext
Loop
' close the document

act.close
set rsQuery= Nothing

else
response.redirect("Sorry.asp")
end if
Reply With Quote
  #2 (permalink)  
Old 02-21-06, 04:34
Td04 Td04 is offline
Registered User
 
Join Date: Mar 2004
Posts: 52
You could always do like this and let the user save his excelsheet instead, otherwise no clues..

Code:
<html>
<%Response.ContentType = "application/vnd.ms-excel"%>
<head></head>
<body>
<%
strLine="" 'Initialize the variable for storing the filednames

For each x in rsQuery.fields
strLine= strLine & x.name & chr(9)
Next

Do while Not rsQuery.EOF
strLine=""
for each x in rsQuery.Fields
strLine= strLine & x.value & chr(9)
next
response.write strLine
rsQuery.MoveNext
Loop
' close the document 

set rsQuery= Nothing

<%>
</body>
</html>
__________________
"Never underestimate a large number of morons"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On