Link to home
Start Free TrialLog in
Avatar of TCCIRM
TCCIRMFlag for United States of America

asked on

String Function error

The code below worked when I used "Request.Form" to capture the form objects and process them.  I installed UploadASP which required me to change the form type to "enctype="multipart/form-data""  Thus I now use "Request.Upload" to capture the form objects.  However, this has caused an error I do not understand.  Why might this no longer work?  Do you see another way to create a loop?  Thanks

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Right'
/Warehouse/Shop/admin/updateItem_pro.asp, line 69

      <%
            iID = Upload.Form("iID")
            sql = "SELECT * FROM inventory WHERE iID=" & iID & ";"
            set rs = Server.CreateObject ("ADODB.Recordset")
            rs.open sql, conn, adOpenKeyset, adLockOptimistic
            if not rs.eof or not rs.bof then
                  rs.movefirst
                  %>
      <%
                  for each item in Upload.Form
                  'response.write item & ": "
                                 --  Error --      iName = right(item, len(item)-3)
                        if left(item,3) = "rs_" then
                              if len(Upload.Form(item)) > 0 then
                                    rs(iName) = Upload.Form(item)
                                    'response.write request(item)  & ": " & item & "<br>"
                              'else
                                    'rs(iName) = NULL
                              end if
                        end if
                  next
                  rs.update
            end if
            rs.close
      els

By the way I commented out the code causing the error and wrote out the form objects:  
100-100: 100-100-011: Sweeper: FOR COARSE/ HEAVY SWEEP. TAMPICO FIBERS RESIST HEAT AND CHEMICALS. 2 1/2" TRIM BY 24" WIDE. : : : PLB-20224: EACH: 5: 14.02: 5: 150: 50: : : AIB: 1: Submit:
Avatar of TCCIRM
TCCIRM
Flag of United States of America image

ASKER

Ooops... I used "Upload.Form" not "Request. Upload" to capture form objects.
you should use mid() function.

iName = mid(item, len(item)-3, 3)
Avatar of TCCIRM

ASKER

No Joy...

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Mid'
try,
for each item in Request.Form
for each item in Request.Form
                  'response.write item & ": "
                                 --  Error --      iName = right(item, len(item)-3)
                        if left(request.form(item),3) = "rs_" then
                              if len(request.Form(item)) > 0 then
                                    rs(iName) = request.Form(item)
                                    'response.write request(item)  & ": " & item & "<br>"
                              'else
                                    'rs(iName) = NULL
                              end if
                        end if
                  next
Avatar of TCCIRM

ASKER

That is what it orginally was and worked fine, but when I changed the form type to enctype="multipart/form-data" I had to change Request.Form to Upload.Form to allow the upload function to work as well as capture the form objects for the update.
ASKER CERTIFIED SOLUTION
Avatar of CWS (haripriya)
CWS (haripriya)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RichardPogson
RichardPogson

The upload form item would seem to have a length less than 3 and the right function is falling off the end of the string hence the error. Was it the item name you wanted to process in which case you want
Right(item.name,len(item.name)-3) If not try writing out each item using On Error Resume Next to see which is giving you greif.
Avatar of TCCIRM

ASKER

Good thought...  I changed it to:  iName = right(Upload.Form(item), len(Upload.Form(item))-3)  
and got the following error on the same line:

Persits.Upload.1 error '800a0009'
index out of range.

So..... it looks like the string function correction worked, but I am now back to square one....  hmmmmmm....
Avatar of TCCIRM

ASKER

I think I am going to try to rewrite the loop....    thanks