Forums
This topic is locked
Write to local text File - with and without ASP?
Posted 04 Oct 2001 10:20:29
1
has voted
04 Oct 2001 10:20:29 jamie logan posted:
Is it possible from a form, once submitted - the system then creates a text file that will be saved as the name of one of the fields?i.e. - instead of submitting to database fields - writing to a text file
Replies
Replied 05 Oct 2001 18:22:59
05 Oct 2001 18:22:59 Paul Rossiter replied:
This is a basic text file writer that uses ASP (VB Code) to write a text file named after the recordset name. You could probably adapt it to create a text file from a form
Replace all instances of...
'example' with your recordset name (this is also the name of your file)
'FieldA' with your first field value
'FieldB' with your first field value
'FieldC' with your first field value
<%
Dim VarField1
Dim VarField2
Dim VarField3
Dim RepeatExample__numRows
Dim RepeatExample__index
%>
<% Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
Set objTS = objFSO.CreateTextFile("Example.txt"
objTS.WriteLine"Header_Name_1" & ", " & Header_Name_1"&", " &"Header_Name_1"
objTS.WriteLine(" "
RepeatExample__numRows = -1
RepeatExample__index = 0
Example_numRows = Example_numRows + Repeat__numRows
While ((RepeatExample__numRows <> 0) AND (NOT Example.EOF))
VarField1=Example("FieldA"
VarField2=Example("FieldB"
VarField3=Example("FieldC"
objTS.WriteLine(VarField1) & ", " & (VarField2)& ", " & (VarField3)
RepeatExample__index=RepeatExample__index+1
RepeatExample__numRows=RepeatExample__numRows-1
Example.MoveNext()
Wend
objTS.Close
Set objTS = Nothing
Set objFSO = Nothing
%>
Hope this helps
Edited by - paulo on 10/05/2001 18:24:39
Replace all instances of...
'example' with your recordset name (this is also the name of your file)
'FieldA' with your first field value
'FieldB' with your first field value
'FieldC' with your first field value
<%
Dim VarField1
Dim VarField2
Dim VarField3
Dim RepeatExample__numRows
Dim RepeatExample__index
%>
<% Set objFSO = Server.CreateObject("Scripting.FileSystemObject"

Set objTS = objFSO.CreateTextFile("Example.txt"

objTS.WriteLine"Header_Name_1" & ", " & Header_Name_1"&", " &"Header_Name_1"
objTS.WriteLine(" "

RepeatExample__numRows = -1
RepeatExample__index = 0
Example_numRows = Example_numRows + Repeat__numRows
While ((RepeatExample__numRows <> 0) AND (NOT Example.EOF))
VarField1=Example("FieldA"

VarField2=Example("FieldB"

VarField3=Example("FieldC"

objTS.WriteLine(VarField1) & ", " & (VarField2)& ", " & (VarField3)
RepeatExample__index=RepeatExample__index+1
RepeatExample__numRows=RepeatExample__numRows-1
Example.MoveNext()
Wend
objTS.Close
Set objTS = Nothing
Set objFSO = Nothing
%>
Hope this helps
Edited by - paulo on 10/05/2001 18:24:39
Replied 25 Jan 2003 05:03:15
25 Jan 2003 05:03:15 Auz Clement replied:
I am having problems with this. This is my code:
<%
'***Write The Corresponding .M3U File for the .MP3------------------------
dim song
song=rsArtistSongs.Fields.Item("song_url"
.Value
song=Replace(song,".mp3",".m3u"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
dim objTS
Set objTS = objFSO.CreateTextFile("www.schiphop.com/artist_songs/"&song,2,true)
objTS.WriteLine("www.schiphop.com/artist_songs/"&rsArtistSongs.Fields.Item("song_url"
.Value)
objTS.Close
Set objTS = Nothing
Set objFSO = Nothing
%>
This is the error messag i am getting:
Microsoft VBScript runtime error '800a0034'
Bad file name or number
/new_artist/new_artist_upload_song_verify.asp, line 67
any help appreciated. thanks
John Auzheal Clement
(www.digitm.com)
<%
'***Write The Corresponding .M3U File for the .MP3------------------------
dim song
song=rsArtistSongs.Fields.Item("song_url"

song=Replace(song,".mp3",".m3u"

Set objFSO = Server.CreateObject("Scripting.FileSystemObject"

dim objTS
Set objTS = objFSO.CreateTextFile("www.schiphop.com/artist_songs/"&song,2,true)
objTS.WriteLine("www.schiphop.com/artist_songs/"&rsArtistSongs.Fields.Item("song_url"

objTS.Close
Set objTS = Nothing
Set objFSO = Nothing
%>
This is the error messag i am getting:
Microsoft VBScript runtime error '800a0034'
Bad file name or number
/new_artist/new_artist_upload_song_verify.asp, line 67
any help appreciated. thanks
John Auzheal Clement
(www.digitm.com)