469,325 Members | 1,651 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

comparing array with a data base value

i want to compare the array value with the data base value

how can i do this

please help

Pramod mujumdar
Aug 13 '07 #1
3 1177
jhardman
3,406 Expert 2GB
Pramod

pretty easily...
Expand|Select|Wrap|Line Numbers
  1. if names("jackson") = rs("names") then
What part is giving you trouble?

Jared
Aug 14 '07 #2
I am not comparing the normal value with the database. Im comparing the Array value. The code which you suggested was for the normal value.
Oct 12 '07 #3
markrawlingson
346 Expert 100+
I think what you are trying to do is see if a value coming from your database can be found within an array.

So if you had a field in the database called Name, we'll say it has a value of "Mark" - (don't know why that name popped into my head :P)

You want to check an array of values to see if "Mark" can be found within that array, is that accurate?

If so, I wrote a function for this task. The only problem with it is that it does not account for multi-dimensional arrays, but i don't suppose you'll need that in this case anyway...

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     Function IsLegitimate(aTemp,sTerm)
  3.         For i = 0 To UBound(aTemp)
  4.             If InStr(aTemp(i), sTerm) > 0 Then
  5.                 IsLegitimate = True
  6.                 Exit For
  7.             Else
  8.                 IsLegitimate = False
  9.             End If
  10.         Next
  11.     End Function
  12.  
  13.    aMyArray = Split("Mark Joe John Sam Charlie Patrick Dick Don Dawn")
  14.  
  15.    If IsLegitimate(aMyArray,rs("DataField")) Then
  16.        Response.Write "Dude... I totally just found the name in the array."
  17.    Else
  18.       Response.Write "Aw shucks, name's not found in the array. What ever shall we do?"
  19.    End If
  20.  
  21. %>
  22.  
Pretty self explanitory, will loop through an array attempting to find whatever value rs("DataField") contains, and return a boolean value of true or false depending on whether the value of rs("DataField") is found within the array or not.

HTH!
Sincerely,
Mark
Oct 12 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Peter | last post: by
3 posts views Thread by George | last post: by
19 posts views Thread by Dennis | last post: by
5 posts views Thread by ma740988 | last post: by
25 posts views Thread by J Caesar | last post: by
2 posts views Thread by TamaThps | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.