Hello everyone!
What: clsUpload.asp and postNew.asp
Why: I am trying to make a new form on a website. (The new form information would be stored in a sql database.) User fills out the form info: form #, title, date due, and filename (has a browse button for user to select the file). Well, once I hit "submit" I keep receiving an error message for my clsUpload.asp page.
Error Message:
[u]
ADODB.Fields error '800a0bb9' </u>
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/ecp/ecpSQL/clsUpload.asp, line 126
The line of code this is referencing is as follows:
rs.fields.append "FileName", 205, LenB(binData)
I can't find any other way to write this.
with the <% On Error Resume Next %> everything will upload and work perfectly. When I remove it, I get the above error. Of course I don't want to leave Error Resume in there so if u can help, I appreciate it.
Thanks in advance.
More code:
clsUpload.asp
Code:
Public Function Save()
if psFileFullPath <> "" and psFileInputName <> "" then
'Save to connectionless client side recordset, write to stream,
'and persist stream.
'would think you should be able to write directly to
'stream without recordset, but I could not get that to work
'On error resume next
binData = o.BinaryDataOf(psFileInputName)
set rs = server.createobject("ADODB.RECORDSET")
rs.fields.append "FileName", 205, LenB(binData)
rs.open
rs.addnew
rs.fields(0).AppendChunk binData
if err.number = 0 then
set objStream = Server.CreateObject("ADODB.stream")
objStream.Type = 1
objStream.Open
Response.Write rs.fields("FileName").value
objStream.SaveToFile psFileFullPath, 2
objStream.close
set objStream = Nothing
End if
rs.close
set rs = nothing
psError = Err.Description
else
psError = "One or more required properties (FileFullPath and/or FileInputName) not set"
End If
End Function
postNew.asp
Code:
Dim sFile
Dim o
set o = new clsUpload
if o.Exists("submitButton") then
'get client file name without path
sFileSplit = split(o.FileNameOf("ecpFilename"), "\")
sFile = sFileSplit(Ubound(sFileSplit))
'Upload filename
o.FileInputName = sFile
o.FileFullPath = Server.MapPath(".") & "\ecpFiles\" & sFile
o.save
end if
if (o.FileNameOf("ecpFilename")) <> "" then
'If not error redirect to complete message
if o.Error = "" then
Dim pEcpNumber, pEcpTitle, pEcpFilename, pEcpOriginator, pEcpDateDistributed, pEcpDateDue, objCommand
Dim pEcpSMEcomplete, pEcpPMcomplete
pEcpNumber = o.ValueOf("ecpNumber")
pEcpTitle = o.ValueOf("ecpTitle")
pEcpFilename = sFile
pEcpOriginator = o.ValueOf("ecpOriginator")
pEcpOriginator = Session("UserFullName")
pEcpDateDistributed = CStr(date())
pEcpDateDue = CStr(o.ValueOf("ecpDateDue"))
pEcpSMEcomplete = ""
pEcpPMcomplete = ""
T.B.
[email protected]