Tried every combo I can think of: String.Empty, IsDBNull.
selectPONumber is passed to “ByVal selectPONumber() As String” from “selectPONumber: [‘ + JSON.stringify(”) + ‘]”
The StackTrace point to the second line of this VB
VB
If Not IsDBNull(selectPONumber) Then
If selectPONumber.Length > 1 Then
qry = qry + "and ("
For u As Integer = 0 To selectPONumber.Length - 1
If u <> selectPONumber.Length Then
qry = qry + "and B.PONumber = '" & selectPONumber(u) & "' or "
Else
qry = qry + "and B.PONumber = '" & selectPONumber(u) & "'"
End If
Next
qry = qry + ") "
Else
qry = qry + "and B.PONumber = '" & selectPONumber(0) & "' "
End If
End If
Many thanks in advance!
Update
Replaced all lengths with counts, and took tranceporter’s advice. Now, it gives the same error on the “for” line. How did it make it past the If selectPONumber.Length > 1 ?
Updated Code
If selectPONumber IsNot Nothing AndAlso selectPONumber.Count > 1 Then
qry = qry + "and ("
For u As Integer = 0 To (selectPONumber.Count - 1)
If u <> selectPONumber.Count Then
qry = qry + "B.PONumber = '" & selectPONumber(u) & "' or "
Else
qry = qry + "B.PONumber = '" & selectPONumber(u) & "'"
End If
Next
qry = qry + ") "
ElseIf selectPONumber(0) <> "" Then
qry = qry + "and B.PONumber = '" & selectPONumber(0) & "' "
End If
Solution
tranceporter’s solution is correct. I stupidly treated a regular string as an array elsewhere in my code. It started pointing all over the rest of the function as indexoutofbounds.
try using this (unless you already have)