Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: array not fully populated

Results 1 to 5 of 5
Share This Thread →
  1. #1
    twisted-pixel is offline Contributing User
    Join Date
    May 2004
    Posts
    52
    Rep Power
    10

    array not fully populated

    Hi clever people (thought I'd start with a bit of flattery)

    I have a calendar on one of my sites that uses various tables to pull the information from. One of these tables is the Event Type, which contains the colour in which the link should be displayed.

    so the table looks like this

    TypeID, Name, Colour
    1, League, Blue
    2, Social, Red

    There are 7 entries in total.

    I read these into an array

    Code:
    Set rsTypes = Server.CreateObject("ADODB.Recordset")
    rsTypes.Open "SELECT * FROM Type", Conn, 3, 3
    dim colorArray
    colorArray=rsTypes.GetRows

    In the Events table, I have an EventType that links it to the Type Table, and I use the following code to compare the type from the Events Table, with the Type in the array to get the colour

    Code:
    For i = LBound(colorArray) TO UBound(colorArray)
       If colorArray(0,i) = (rsEventsDay("EventType")) Then
       colorLink = colorArray(2,i)
    Next
    but, the problem I'm having is that for some reason (and I can't work out why), it only ever reads the first three records from the type table

    I've added a response.write in the code to check what the array is, and this only outputs the first 3 records

    Code:
    For i = LBound(colorArray) TO UBound(colorArray)
       Response.write colorArray(0,i)
       If colorArray(0,i) = (rsEventsDay("EventType")) Then
       colorLink = colorArray(2,i)
    Next
    I wondered if it was something else in the code that was affecting this, so I wrote

    Code:
    Set rsTypes = Server.CreateObject("ADODB.Recordset")
    rsTypes.Open "SELECT * FROM Type", Conn, 3, 3
    dim colorArray
    colorArray=rsTypes.GetRows'(7,1,2)
    For i = LBound(colorArray) TO UBound(colorArray)
    response.write i & " - " & colorarray(0,i) & " <BR> 
    next
    but the output is still only the first 3 rows....anyone have any ideas as to why? Is it related to the fact that there are 3 fields and so the array is being limited to just 3 records?
    Last edited by twisted-pixel; January 7th, 2013 at 03:51 AM.

  2. #2
    twisted-pixel is offline Contributing User
    Join Date
    May 2004
    Posts
    52
    Rep Power
    10
    figured it out...it needs to be

    Code:
    For i = LBound(colorArray,2) TO UBound(colorArray,2)

  3. #3
    gk53's Avatar
    gk53 is offline Contributing User
    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,538
    Rep Power
    278
    I just do not understand why you need arrays? If you have recordsets originally you can compare values in recordsets, just set cursor location to client, open as keyset and set active connection to nothing. After that you can filter, or loop thru you recordsets and it will be mach simpler and faster
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree

  4. #4
    twisted-pixel is offline Contributing User
    Join Date
    May 2004
    Posts
    52
    Rep Power
    10
    essentially, I'm doing it because I'm opening multiple recordsets...so I load the data from one into an array, and then use this array to compare against when opening subsequent recordsets

  5. #5
    gk53's Avatar
    gk53 is offline Contributing User
    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,538
    Rep Power
    278
    I understand that and you do not need that array, you can have disconnected recordset and do the same compare or just join tables on SQL and get results from database...

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Filter populated dropdown
    By ElPazzo in forum HTML, JavaScript And CSS Help
    Replies: 0
    Last Post: August 2nd, 2012, 04:45 PM
  2. Replies: 2
    Last Post: June 27th, 2010, 10:02 AM
  3. Database not being populated
    By Jamiex in forum ASP Development
    Replies: 7
    Last Post: December 27th, 2007, 05:36 AM
  4. Querystring populated with a DB Value
    By zwieback89 in forum ASP Development
    Replies: 10
    Last Post: December 14th, 2006, 08:10 PM
  5. Additioning a non populated cel
    By MARKEDAGAIN in forum Microsoft Access Help
    Replies: 3
    Last Post: December 29th, 2004, 10:54 PM

ASP Free Advertisers and Affiliates