Forum Moderators: open
I want to write certain data from an HTML form into a text file using ASP.
It is writing into the file but...sometimes once, twice, thrice. Any idea why this unusual behavior. I have been trying to figure this out!
Here is my code:
<%
'Hier der Block für die Automatisierung
'**************************************
Dim TextFile, Header
dim vorname, nachname, personalnummer, netid, datum
TextFile = Server.MapPath ("../Test") & "\daten.txt"
vorname = request.form("vorname")
nachname = request.form("nachname")
personalnummer = request.form("personalnummer")
netid = request.form("netid")
Tag = Day(date)
Monat=Month(date)
Jahr=Year(date)
datum=Tag & "." & Monat & "." & Jahr
text = ""
text = datum & ";" & vorname & ";" & nachname & ";" & personalnummer & ";" & netid & ";"
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set OutStream = FileObject.OpenTextFile (TextFile, 8,true)
OutputString = text
OutStream.WriteLine OutputString
OutStream.Close
Set OutStream = Nothing
Set FileObject = Nothing
%>
I did not quite get ur question.
You are right i have to append the data to the file ...if the file already exists when there is a new entry, else the code creates a new file and writes into it.
That is why i have used 8.
Now what exactly is the problem? I would be grateful if u could help me solve thos problem. The data is repeating and it makes no sense to have the same data many times.