I have an asp page that I would like to create a log of certain data. I tried using the FileSystemObject, but came to a problem because some of the data I am saving has extended Ascii characters(code 180 i believe), which FSO didn't like. I kept getting "Invalid procedure call or argument" when trying to write specfic lines. It would write the lines just fine up until that point.
I need to be able to write any character I please to a file, and have it written exactly as I specify.
Next I tried ADODB.stream to solve my problem. After hours of trying to decipher vague error messages, I actually got it to almost work once. It wrote some data to a file, but prefixed my data with a couple bogus characters that were not part of my data. In addition to that, I cannot figure out a way to append data to a file as opposed to replacing the file with entirely new data.
After getting it almost working once, ADODB.Stream refuses to cooperate once again. I receive this error when
ADODB.Stream error '800a0bbc'
Write to file failed.
Here is some code that I was working with:
Const adTypeBinary = 1
Const adTypeText = 2
Const adSaveCreateNew = 1
Const adSaveCreateOverWrite = 2
'Create Stream object
Dim BinaryStream2
Set BinaryStream2 = CreateObject("ADODB.Stream
")
'Open the stream And write binary data To the object
BinaryStream2.Type = adTypeText
BinaryStream2.Open
Response.Write ReadBinaryFile(Server.MapP
ath("Maile
r.log"))
BinaryStream2.WriteText "DATE:" & Now & vbCrLf & vbCrLf
BinaryStream2.WriteText "XML.RESPONSETEXT:" & vbCrLf & xml.responseText & vbCrLf
BinaryStream2.WriteText "FORM DATA SUBMITTED:" & vbCrLf
dim data_piece
for each data_piece in Request.Form
if instr(ucase(data_piece),"C
C")=0 and instr(ucase(data_piece),"C
REDIT")=0 then'don't log credit card data
BinaryStream2.WriteText data_piece & ": " & Request(data_piece) & vbCrLf
end if
next
BinaryStream2.WriteText "EMAIL BODY:" & vbCrLf & email_string
'Save binary data To disk
BinaryStream2.SaveToFile Server.MapPath("Mailer.log
"), adSaveCreateNew ' this is the line causing the current error
What I assumed would be an incredibly simple thing to do is turning into a nightmare. Why won't asp just treat my data like data and write it to the file when I tell it to. I'd rather be coding in C, a language that doesn't defy all logic.
Start Free Trial