|
 |
access_asp thread: Error in : creating excel file using ASP
Message #1 by syed moiz <sa_moiz@y...> on Sun, 26 Jan 2003 23:26:27 -0800 (PST)
|
|
Hi,
iam using this ASP file to flush content from database
into notepad , with an link to excel file.
but this file is giving error.
on this line
Error Line: ### MyFile.writeline strLine ###
Error Description : Invalid Procedure Call.
Can anyone help me out to get rid of this problem.
Thanks
Sample File
__ __ __ _
#############################################################################################################################
<%@ LANGUAGE="VBSCRIPT" %>
<!--#include file="conn.inc" -->
<HTML>
<HEAD>
<TITLE>Text File</TITLE>
</HEAD>
<body>
<%
'Create a randome Filename
nRandom = Int((1000000 - 1 + 1) * Rnd +
1000000)
fileExcel = "t" & CStr(nRandom) & ".xls"
'Replace 'MyWeb' with your virtual directory
name or just the
'slash if it is at the wwwroot.
filePath= Server.mapPath("\sam")
filename=filePath & "\" & fileExcel
Set fs
Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = fs.CreateTextFile(filename,
True)
Set cn
Server.CreateObject("ADODB.Connection")
cn.Open( myConnStr)
Set rs = cn.Execute("SELECT ProductID,
ProductName, SupplierID FROM Products")
strLine=""
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
MyFile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
MyFile.writeline strLine
rs.MoveNext
Loop
MyFile.Close
Set MyFile=Nothing
Set fs=Nothing
'Show a link to the Excel File.
link="<A HREF=" & fileExcel & ">Open
Excel</a>"
Response.write link
%>
</BODY>
</HTML>
#############################################################################################################################
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
|
|
 |