This is the code on a page where I am trying to delete a number or records form a database and images from a file on server.
The first page displays all the images with a check box beside each image to select it you want to delete the image. When this page is submitted it goes to a page where the id numbers of each record are taken and stored in an array, when looping through the code to delete the images I get the following error:
(First 3 lines - just to check code)
Upperbound = 1
IDno(0) = 36 Select * From Images WHERE id =36
IDno(1) = 37 Select * From Images WHERE id =37
Microsoft VBScript runtime error '800a0009'
Subscript out of range: '2'
/cp/gallerydelete.asp, line 24
The Code on the page:
dim rs, cn, i, j
idnos=split(idno,", ") ' stores the values in the arrays
response.write ("Upperbound = " & Ubound(idnos))
if not checkcount <1 then
set cn = server.createobject("ADODB.Connection")
cn.provider = application("strProvider")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
for i = 0 to checkcount
response.write("<br>IDno(" & i & ") = " & idnos(i) & " ") <<<<<<<< line with error
strSQL="Select * From Images WHERE id =" & idnos(i)
set rs = cn.execute(strSQL)
objFSO.DeleteFile Server.mapPath("/galleryimages/") & "\" & rs.fields("Imagename"), False
Set objFSO = Nothing
set rs = nothing
sSQL = "DELETE from Images WHERE Id IN(0,0" & Request("chk") & ")"
set cn = nothing