TCCIRM
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-d ata"" 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/upda teItem_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:
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Right'
/Warehouse/Shop/admin/upda
<%
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:
you should use mid() function.
iName = mid(item, len(item)-3, 3)
iName = mid(item, len(item)-3, 3)
ASKER
No Joy...
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Mid'
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Mid'
try,
for each item in Request.Form
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
'response.write item & ": "
-- Error -- iName = right(item, len(item)-3)
if left(request.form(item),3)
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
ASKER
That is what it orginally was and worked fine, but when I changed the form type to enctype="multipart/form-da ta" 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.n ame)-3) If not try writing out each item using On Error Resume Next to see which is giving you greif.
Right(item.name,len(item.n
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....
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....
ASKER
I think I am going to try to rewrite the loop.... thanks
ASKER