Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2006, 11:02 AM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default Uploading File

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]
__________________
T.B.
[email protected]
 
Old October 26th, 2006, 12:28 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

O.o I don't know. I *think* it have to do with LenB() in your recordset but I am not sure since everything looks to be in order otherwise.

Is lenB() returning a value?

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 01:53 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

Yea I was looking at the LenB too. No it's not returning a value.
And everything is right (compared to the info I found on-line).

From researching the internet I found that rs.append normally has about four parameters.
That one only had three. However, adding a fourth one (like AdFieldIsNullable) does not help.

Also, some websites i searched suggested that I may have
the datatype for "fieldname" (declared public FieldName in my clsUpload page) declared differently in clsUpload than I do in the database. But
I looked at the database and I have ecpFilename (how named in database) set as nvarchar and I changed the 205 to 200 for the
adVarChar in adovbs.inc. Well, that didn't work either. So I have no idea what's going on with it.

Thanks for the reply, I'll figure it out eventually, God willing. ;)

T.B.
[email protected]
 
Old October 26th, 2006, 02:15 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First, dont 205 is fine because that is VarBinary (which is what you are uploading) I have only ever used rs.append such as

rs.append [fieldname], [datatype], [length] so if your length is returning 0 that could be the problem; a varbinary field in MSSQL can have a max length of 8000, you can try statically setting 8000 as the number as opposed to bLen() and see if that helps.


-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 02:56 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

no luck

T.B.
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading a file MunishBhatia ASP.NET 2.0 Professional 4 May 30th, 2007 04:18 AM
Uploading a file with ASP BananaJim Classic ASP Professional 1 December 7th, 2006 06:57 PM
file uploading lakshmi devi Classic ASP Basics 2 September 3rd, 2006 11:52 PM
FIle Uploading [email protected] Classic ASP Basics 3 February 23rd, 2004 12:32 PM
File uploading zabedin Classic ASP Basics 1 July 16th, 2003 08:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.