Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Output from asp to file

Posted on 2003-12-09
5
Medium Priority
?
278 Views
Last Modified: 2012-08-14
Hi , i want to output some Calendar data from asp ( would be coming from access db in backend) to a txt file in the format..

Name: Test
Address: Forest Lane
Country: Ireland

Any ideas?

Im trying to output in VCS extension and so use with Outlook...

thanks

Stephen
0
Comment
Question by:sgriffin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9906193
@sgriffin:

> Hi , i want to output some Calendar data from asp ( would be coming from access
> db in backend) to a txt file in the format..

You should use the "Scripting.FileSystemObject".  A small sample of its use would look like this:
   Dim fso
   Dim ts
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set ts = fso.CreateTextFile("SOMEPATH\Event.VCS", True)
   ts.WriteLine "Name: " & RS("Name")
   ts.WriteLine "Address: " & RS("Address")
   ts.WriteLine "Country: " & RS("Country")

Then you can just add a link to the .VCS file.


Hope That Helps,
Dex*
0
 
LVL 2

Author Comment

by:sgriffin
ID: 9906200
will try , thanks!
0
 
LVL 2

Author Comment

by:sgriffin
ID: 9906205
would it be possible to delete the vcs after?
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9906223
Sure the "Scripting.FileSystemObject" has facilities for deleting files as well.  All of the methods and properties are documented here:
      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsobjFileSystem.asp

Enjoy!

D*
0
 
LVL 4

Accepted Solution

by:
Iguanasan earned 200 total points
ID: 9907450
Here you go.  All you need to do is adjust this to get the data from the database instead of the URL.  Also, if you fix the DateToUTC I'd appreciate it if you could flip it back to me either through this forum or via email, Iguanasan*AT*hotmail*DOT*com.

<% Option Explicit ' Ensure Variable Usage is Unique %>
<!--#include file="functions.asp" -->
<%

'
' Define Variables and constants.
'
'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4
'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004
Const adCmdFile = &H0100
Const adCmdTableDirect = &H0200

Dim dtDate, dtTime, FileName
Dim CRLF ' Carriage Return Line Feed
Dim QQ   ' Double Quote
CRLF = Chr(13) & Chr(10)
QQ = Chr(34)

FileName = Request.QueryString("Event")
If Len(FileName) > 0 Then
    FileName = Replace(FileName," ","_")
Else
    FileName = "untitled"
End If
FileName = FileName & ".ics"

Response.Expires = 0
Response.Buffer = True
Response.Clear
Response.ContentType = "text/calendar"
Response.AddHeader "content-disposition", "attachment; filename=""" & FileName & """"
Response.Write "BEGIN:VCALENDAR" & CRLF
Response.Write "VERSION:0.1" & CRLF
Response.Write "PRODID:-//immediaC/webcal//NONSGML v1.0//EN" & CRLF
Response.Write "BEGIN:VEVENT" & CRLF
dtDate = Request.QueryString("start")
dtTime = TimeValue(dtDate)
dtDate = DateValue(dtDate)
Response.Write "DTSTART:" & dateToUTC(dtDate,dtTime) & CRLF ' 19970714T170000Z
dtDate = Request.QueryString("end")
dtTime = TimeValue(dtDate)
dtDate = DateValue(dtDate)
Response.Write "DTEND:" & dateToUTC(dtDate,dtTime) & CRLF ' 19970715T035959Z
Response.Write "SUMMARY:" & Request.QueryString("Event") & CRLF 'Bastille Day Party
If Len(Request.QueryString("Location")) > 0 Then
    Response.Write "LOCATION:" & Request.QueryString("Location") & CRLF
End If
Response.Write "DESCRIPTION:" & Fold(Request.QueryString("Details")) & CRLF
Response.Write "END:VEVENT" & CRLF
Response.Write "END:VCALENDAR" & CRLF
Response.End

Function Fold(byRef sString)
      if Len(sString) > 0 then
            Fold = Replace(sString,CRLF,CRLF & " ")
      end if
End Function

Function dateToUTC (sDate, sTime)
' returns a UTC-formatted string describing the date and time
' The UTC format is YYYYMMDDTHHMMSS plus Z for Greenwich Mean Time

'
' this thing doesn't take into consideration Daylight Saving Time.  I'm going to have to adjust for that.
' For now I'm switching to a 3 hour offset.
' According to this site: http://webexhibits.org/daylightsaving/b.html
' North America: United States, Canada, Mexico, St. Johns, Bahamas, Turks And Caicos
' Start: First Sunday In April
' End: Last Sunday In October
' See http://webexhibits.org/daylightsaving/g.html for more details.
'
'
Dim iHour, iMin, iYear, iMonth, iDay, tDate, tTime
tDate = DateValue(sDate)
tTime = TimeValue(sTime)
iHour = Hour(DateAdd("h", 3, tTime)) 'correction for US Eastern time
iMin = Minute(tTime)
iYear = Year(tDate)
iMonth = Month(tDate)
iDay = Day(tDate)
If iHour < 3 Then
    iDay = iDay + 1
End If
      
Dim s : s = iYear
If iMonth < 10 Then s = s & "0"
s = s & iMonth
If iDay < 10 Then s = s & "0"
s = s & iDay & "T"
If iHour < 10 Then s = s & "0"
s = s & iHour
If iMin < 10 Then s = s & "0"
s = s & iMin & "00Z"
dateToUTC = s

End Function
%>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question