Results 1 to 7 of 7
  1. #1
    Join Date
    May 2003
    Posts
    9

    Unanswered: Select a specific record

    Hi,

    Is it possible to select a specific record from a recordset?

    If I have a recordset (always has 10 records)

    Can I specify a particular records on a page, so that I can place records in different places.


    Thanks,

    Sanjay

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191

    not sure what you want to do....

    If rs represents your recordset, then

    Use rs.movefirst to go to the first record,
    rs.movenext to increment to the next record,
    rs.eof to check for end of file, etc.

    You should just enter 'recordset object' into your prefered internet search engine, and you'll get the full set of available properties and methods.

    Tim
    Tim

  3. #3
    Join Date
    May 2003
    Posts
    9
    Thanks Tim,

    I understand that you are able to use the 'move' but how do you translate this to a vlaue say for the 3rd record of rsRecordset1

    <%=(rsRecordset1.Fields.Item("CATSRAvg").Value)% >

    where is the normal record value?

    Regards,

    Sanjay

  4. #4
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191

    ??? still not sure what you're after

    I understand that you are able to use the 'move' but how do you translate this to a vlaue say for the 3rd record of rsRecordset1

    <%=(rsRecordset1.Fields.Item("CATSRAvg").Value)% >

    where is the normal record value?
    The recordset objet exposes one record at a time. If you want to deal with the values in another record, you must first move to it. You cannot work with the values of two or more records at once unless you have two recordsets open.

    You CAN capture field values for one or more records at once into an array variable using the getrows or getstring methods. These methods put all the field values into an array that you can then use in your code however you want. If this is what your after I would suggest you read up on the getrows method.

    Does this answer your question?

    Tim
    Tim

  5. #5
    Join Date
    May 2003
    Posts
    9
    I think so,

    So am I able to get the values from record 1, 4, 10 of a recordset using the getrows?

    or do I need to open the recordset get record value 1 close the recordset, open the recordset get the values of record 4 close it etc

    Regards,

    Sanjay

  6. #6
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191

    example info

    The getrows method takes the form of:

    arrVariable= recordsetobject.GetRows (Rows, Start, Fields)

    where rows=number of rows to return, start=the record to start at (0=current, 1=first, 2=last) and fields= a single field name or an array of field names or an array of ordinal positions of the fields.The order in which the field names are listed dictates the order in which they are returned.


    So in your case, if you want to use rows 1, 4 and 10, you would do:

    arrDBvalues=rs.getrows(10,0)

    Using this method as shown in the above command line, the array arrDBvalues is then automatically populated with the values of all the fields of all the records from the starting record to the 10th record.

    You could then manipulate the values of the records from the contents of the arrDBvalues array.

    Note that this allows you to open the recordset, do the getrows command to capture ALL the data values at once, and then close the recordset immediately. (Very efficient and very good programming practice). Then, the values are stored in the 2 dimensional array arrDBvalues for you to use however you wish.

    Hope this helps.

    Type Getrows into your favorite search engine, and you'll get a lot of websites with good examples of how to use it.

    Tim
    Tim

  7. #7
    Join Date
    May 2003
    Posts
    9
    Thanks Tim,

    This could very useful since I also ran into a problem where I got a error:

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
    [Microsoft][ODBC Microsoft Access Driver] Too many client tasks.

    This is because I have far too many recordsets (its a summary table) I will use this instead or this

    <%
    set oRs = server.createobject("adodb.recordset")
    oRs.open "select....", ConnectionString
    aData = oRs.getrows
    oRs.close
    %>

    Sanjay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •