Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

seems an array problem in asp

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL
Very strange.
I'm comparing a value from an array to a field in the database, in a "for" loop, for each record.
The first cell in the array, never matches, though there IS a match in one of the records (I mean that it acts as if there is no match).
The next cells r doing great.
The wierd thing is that when I replace the first value with other value in the array (switch places), again the first (now different) value never matches, and the one that did not match before does now.
When I don't use the loop and not an array, but just put a string and compare it to the field, it's ok too.
Seems I'm not aware of something in the array or loop things.
I checke dthe values in the array, and also in the fields, and checked if each cell is checked, and all r true.
I USE:
dim match
match="no"
for iLoop=LBound(MyArray) to UBound(MyArray)
if rs.fields("myField")=MyArray(iLoop) then
Response.Write(&quot;<td align=center><IMG src=picture1.gif'></td>&quot;)
match=&quot;yes&quot;
end if
Next

-------------------------------
If I just try comparing(no loops, no for)in the following way, I have no probelm:
if rs.fields(&quot;myField&quot;)=&quot;typingfirstValue&quot; then
Response.Write(&quot;<td align=center><IMG src=picture1.gif'></td>&quot;)
match=&quot;yes&quot;
end if

Thanks
 
Check if your database field rs.fields(&quot;myField&quot;) has an fixed lenght if so when u compare rs.fields(&quot;myField&quot;) if had 20 length (including spaces) with the right string u won't get match

like:
&quot;myField&quot; in your database is declare char or something elese not varchar or...

if u insert an value in &quot;myField&quot; u always get a string with the size of the field
rs.fields(&quot;myField&quot;) is 20 long string

inserting &quot;test value&quot; - 10 char long
the rs.fields(&quot;myField&quot;) will be &quot;test value &quot; 20 char long

and when compare rs.fields(&quot;myField&quot;)=&quot;test value&quot; wont match...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top