472,096 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

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 1203
3,406 Expert 2GB

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

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
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
  13.    aMyArray = Split("Mark Joe John Sam Charlie Patrick Dick Don Dawn")
  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
  21. %>
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.

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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.