kwcowboy1226
asked on
Error Type:Microsoft VBScript runtime (0x800A0009) Subscript out of range: '5'
Below is the code that generated the error:
Dim i
Dim j
Dim intContactId(4)
Dim intAddressId(4)
strStudentContact = "exec ssrSP_GetStudentContact '" & strKISDID & "'"
set rsStudentContact = ExecSQLRS(strStudentContac t)
if not rsStudentContact.EOF then
i=0
do while not rsStudentContact.EOF
intContactId(i) = rsStudentContact.Fields("C ontactId")
strContact = "exec ssrSP_GetContact '" & intContactId(i) & "'"
set rsContact = ExecSQLRS(strContact)
if not rsContact.EOF then
j=0
do while not rsContact.EOF
intAddressId(j) = rsContact.Fields("AddressI d")
j =j+1
Loop
end if
set rsContact = nothing
i = i+1
Loop
end if
rsStudentContact = nothing
Dim i
Dim j
Dim intContactId(4)
Dim intAddressId(4)
strStudentContact = "exec ssrSP_GetStudentContact '" & strKISDID & "'"
set rsStudentContact = ExecSQLRS(strStudentContac
if not rsStudentContact.EOF then
i=0
do while not rsStudentContact.EOF
intContactId(i) = rsStudentContact.Fields("C
strContact = "exec ssrSP_GetContact '" & intContactId(i) & "'"
set rsContact = ExecSQLRS(strContact)
if not rsContact.EOF then
j=0
do while not rsContact.EOF
intAddressId(j) = rsContact.Fields("AddressI
j =j+1
Loop
end if
set rsContact = nothing
i = i+1
Loop
end if
rsStudentContact = nothing
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
You can try this:
Dim i
Dim j
Dim intContactId
Dim intAddressId
strStudentContact = "exec ssrSP_GetStudentContact '" & strKISDID & "'"
set rsStudentContact = ExecSQLRS(strStudentContac t)
if not rsStudentContact.EOF then
do while not rsStudentContact.EOF
intContactId= rsStudentContact.Fields("C ontactId") & ","
strContact = "exec ssrSP_GetContact '" & intContactId(i) & "'"
set rsContact = ExecSQLRS(strContact)
if not rsContact.EOF then
do while not rsContact.EOF
intAddressId= rsContact.Fields("AddressI d") & ","
Loop
end if
set rsContact = nothing
Loop
end if
rsStudentContact = nothing
intContactId = split(intContactId, ",") '<-------create array with all data
intAddressId = split(intAddressId, ",") '<-------create array with all data
for i = 0 to ubound(intContactId)
Response.write "Contact: " & intContactId & "<br>"
next
for i = 0 to ubound(intAddressId)
Response.write "Addresst: " & intAddressId & "<br>"
next
Dim i
Dim j
Dim intContactId
Dim intAddressId
strStudentContact = "exec ssrSP_GetStudentContact '" & strKISDID & "'"
set rsStudentContact = ExecSQLRS(strStudentContac
if not rsStudentContact.EOF then
do while not rsStudentContact.EOF
intContactId= rsStudentContact.Fields("C
strContact = "exec ssrSP_GetContact '" & intContactId(i) & "'"
set rsContact = ExecSQLRS(strContact)
if not rsContact.EOF then
do while not rsContact.EOF
intAddressId= rsContact.Fields("AddressI
Loop
end if
set rsContact = nothing
Loop
end if
rsStudentContact = nothing
intContactId = split(intContactId, ",") '<-------create array with all data
intAddressId = split(intAddressId, ",") '<-------create array with all data
for i = 0 to ubound(intContactId)
Response.write "Contact: " & intContactId & "<br>"
next
for i = 0 to ubound(intAddressId)
Response.write "Addresst: " & intAddressId & "<br>"
next
However, what yu're doing do not look like a good idea. There will be no way to match up your Contact ID with the right AddressID because your building array inside a loop and then another array inside that loop.
So arrau intContactId(1) may contain ID# 10, and array intAddressId(1) may contain ID's 1-10. Then the next would be higher. Maybe I'm missing something, but there's no point in that!
May want to use INNER JOIN query instead of SP.
So arrau intContactId(1) may contain ID# 10, and array intAddressId(1) may contain ID's 1-10. Then the next would be higher. Maybe I'm missing something, but there's no point in that!
May want to use INNER JOIN query instead of SP.
Do you still need assistance with this question? If not, please close...
Thanks.
Thanks.
You have defined arraysize as 4
Dim intContactId(4)
Dim intAddressId(4)
Quickfix...Just increase the array size to say 100 .
Or redim preserve intContactId(TotalNoofreco