PDA

View Full Version : Database Fields


jeremywatco
11-19-2002, 10:42 PM
What is the easiest way to split up values in one database field. For example. Lets say I have a field called numbers and it contains these values: 1,2,3,10,11,12,13 and I want to look at each number individually to compare it with something. What is the easiest way to do this? The values are in a Access 2000 Database.

glenngv
11-20-2002, 01:09 AM
nums = rs("fieldnamehere")
if not isnull(nums) and nums<>"" then
arrNums = split(nums) '2nd parameter is the delimeter and is optional, the default is comma
for each item in arrNums
'code here
next
end if

whammy
11-20-2002, 01:39 AM
Wow Glenn - it looks like you did that as fast as you can type. ;)

I was going to answer the question the same way, but I thought maybe someone had a better solution, so I'd wait it out for a couple of hours... ;)

whammy
11-20-2002, 01:43 AM
P.S. You could also use UBound() to get the upper limit of the array...


nums = Split(numbers)

For i = 0 to UBound(nums)
Response.Write(nums(i) & "<br />" & vbCrLf)
Next

jeremywatco
11-20-2002, 03:21 AM
Thanks! I am pretty new to asp but not to programming. In your if statement. What does the "<>" do?

Thanks.

whammy
11-20-2002, 03:22 AM
<> means "not equal to". :) Just like != in javascript or some other languages.

jeremywatco
11-20-2002, 09:38 PM
Thanks!