|
I have written a page that can output to a word doc, but ran into a problem, I wanted to name the output file the same a the posting, here's the code i've done:
<% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.CacheControl = "no-cache"
%> <!--#include file="db.asp"-->
<% response.buffer = true
'get key key = request.querystring("key") if key="" or isnull(key) then key=request.form("key") end if if key="" or isnull(key) then response.redirect "it_postslist.asp"
'get action a=request.form("a") if a="" or isnull(a) then a="I" 'display with input box end if
' Open Connection to the database set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str
Select Case a Case "I": ' Get a record to display
tkey = key strsql = "SELECT * FROM [Posts] WHERE [PostsNo]=" & tkey
set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn If rs.EOF Then Response.Clear Response.Redirect "it_postslist.asp" Else rs.MoveFirst End If
' Get the field contents x_PostsNo = rs("PostsNo") x_DatePosted = rs("DatePosted") x_Title = rs("Title") x_Post = rs("Post")
rs.Close Set rs = Nothing
End Select %>
<p> <form> <% Response.ContentType = "application/msword" Response.AddHeader "Content-Disposition", "attachment;filename=itpost.doc" %> <table border="0" cellspacing="0" cellpadding="4">
<tr> <td ><font face="Arial" size="1"><B>Title</B>: <% response.write x_Title %></font> </td> </tr> <tr> <td ><font face="Arial" size="1"><B>Post: </B><%= replace(x_Post & "",chr(10),"<br>") %></font> </td> </tr> </table> </form> <p>
can anyone help?, I've highlighted the code that creates the file in blue
Thanx in advance
-------------
http://www.drunkentechie.net - DrunkenTechie.net
You can logoff, but you can never leave
|