Forums

ASP

This topic is locked

Comparing Values In Recordset

Posted 21 years ago
1
has voted
21 years ago dc dc posted:
I am attempting to search the recordset with an array of numbers submitted from a form. I want the script to identify which array of numbers exist in the database and which do not. Script below generates the entire array line by line with "The Value Does Not Exists" even though some numbers in the array exist in the database. My hair is almost gone from trying to solve this mystery!!! Please Help!!

Dim rjn
Dim JobArray
Dim JobValue

JobValue = rs2.Fields.Item("Job".Value
rjn = Request.form("dziad" ' Request Job Numbers from text area line by line from a form
JobArray = Split(rjn,vbCrLf)

For i = 0 to UBound(JobArray)
Do While Not Rs2.EOF
If JobValue = JobArray(i) Then
JobArray(i) = true
End If
rs2.movenext
Loop
If JobArray(i) = true Then
response.write(JobArray(i) & " The Value Exists <br>"
Else
response.write(JobArray(i) & " The Value Does Not Exists <br>"
End If
next

Replies

Replied 21 years ago
21 years ago Vince Baker replied:
A simpler way to do this would be to dim another value, then where you have the jobarray(i) = true replace jobarray(i) with this variable and then end your loop (end for). this would ensure that you are not overwriting your true with a false value when you move to the next item in your loop.

Your check for jobarray(i) would need to be inside another loop to process the logic correctly, but my way you would not have to worry about that.



Regards
Vince

Visit my home: www.chez-vince.com

VBScript | ASP | HTML | SQL | Oracle | Hosting

Reply to this topic