If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Select a specific record

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-03, 13:31
sanjshah sanjshah is offline
Registered User
 
Join Date: May 2003
Posts: 9
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
Reply With Quote
  #2 (permalink)  
Old 05-18-03, 21:47
MrWizard MrWizard is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 05-19-03, 05:45
sanjshah sanjshah is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 05-19-03, 08:03
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
??? still not sure what you're after

Quote:
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
Reply With Quote
  #5 (permalink)  
Old 05-19-03, 08:20
sanjshah sanjshah is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 05-19-03, 10:23
MrWizard MrWizard is offline
Registered User
 
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
Reply With Quote
  #7 (permalink)  
Old 05-19-03, 10:46
sanjshah sanjshah is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On