asp show specific record from recordset

asp show specific record from recordset

am 19.10.2005 14:43:16 von Brian Ciarcia

I know this is a weird request, but lets say I create a recordset with
5 row and 5 columns. How can I, for instance, pull out the record
from row(3) column(2).. I know i can pull from a column by just doing
this, Recordset(2).value, which pulls the record from the 3rd column.
Is there a way to do what I want?

Re: asp show specific record from recordset

am 19.10.2005 15:07:24 von McKirahan

"Brian" wrote in message
news:1129725796.076861.242890@g14g2000cwa.googlegroups.com.. .
> I know this is a weird request, but lets say I create a recordset with
> 5 row and 5 columns. How can I, for instance, pull out the record
> from row(3) column(2).. I know i can pull from a column by just doing
> this, Recordset(2).value, which pulls the record from the 3rd column.
> Is there a way to do what I want?
>

Here's one way:

Dim strRSG
strRSG = Recordset.getString(2,,"|",vbCrLf)
Dim arrRSG
arrRSG = Split(strRSG,vbCrLf)
Response.Write(Split(arrRSG(2),"|")(1))

Re: asp show specific record from recordset

am 19.10.2005 15:07:44 von rdanjou

I thank that the easiest way would be to copy the recordset into an array
using getRows()

"Brian" wrote in message
news:1129725796.076861.242890@g14g2000cwa.googlegroups.com.. .
>I know this is a weird request, but lets say I create a recordset with
> 5 row and 5 columns. How can I, for instance, pull out the record
> from row(3) column(2).. I know i can pull from a column by just doing
> this, Recordset(2).value, which pulls the record from the 3rd column.
> Is there a way to do what I want?
>

Re: asp show specific record from recordset

am 19.10.2005 15:13:04 von reb01501

Brian wrote:
> I know this is a weird request, but lets say I create a recordset with
> 5 row and 5 columns. How can I, for instance, pull out the record
> from row(3) column(2)..

I know, it's pedantic, but I'm sure you meant to say: "how do I pull the
data out of the third field in the fourth record of my recordset?"

Even more pedantic (sorry):
Recordsets have fields and records. Relational databases have rows and
columns.

> I know i can pull from a column by just doing
> this, Recordset(2).value, which pulls the record from the 3rd column.
> Is there a way to do what I want?

Given that you really need to be using a recordset for some reason*, you
need to navigate to the record. Assuming you have a recordset that supports
bookmarks**, then you can use the Move(x) method to navigate to the desired
record - http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthmove .asp

Once you're at the desired record, simply use the statement you show above.

*Instead of, for instance, using GetRows to put the data into a
2-dimensional array, allowing you to close the recordset and connection.
Using a GetRows array relieves you of the need to worry about the
recordset's cursortype: in fact, you can use a forward-only cursor, the most
efficient cursor there is:

set rs=conn.execute("some query",,1)
if not rs.eof then ar = rs.getrows
rs.close: set rs=nothing
conn.close:set conn = nothing
if isarray(ar) then
data = ar(2,3)
else
'recordset was empty
end if

See http://www.aspfaq.com/show.asp?id=2467 for more examples


** Any clientside cursor, or a server-side static, keyset or dynamic
cursor - see this article to learn about the effect that cursortype has on
the ability to navigate through a recordset::
http://msdn.microsoft.com/library/en-us/ado270/htm/mdprocurs ortype.asp
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: asp show specific record from recordset

am 19.10.2005 15:20:47 von McKirahan

"McKirahan" wrote in message
news:ELKdnXAVPu9n2cveRVn-rQ@comcast.com...
> "Brian" wrote in message
> news:1129725796.076861.242890@g14g2000cwa.googlegroups.com.. .
> > I know this is a weird request, but lets say I create a recordset with
> > 5 row and 5 columns. How can I, for instance, pull out the record
> > from row(3) column(2).. I know i can pull from a column by just doing
> > this, Recordset(2).value, which pulls the record from the 3rd column.
> > Is there a way to do what I want?
> >
>
> Here's one way:
>
> Dim strRSG
> strRSG = Recordset.getString(2,,"|",vbCrLf)
> Dim arrRSG
> arrRSG = Split(strRSG,vbCrLf)
> Response.Write(Split(arrRSG(2),"|")(1))


Raymond's right:

Dim strGET
strGET = objRST.GetRows(3,0)
Response.Write(strGET(2,1))

Or some variation thereof.

http://www.w3schools.com/ado/met_rs_getrows.asp

Re: asp show specific record from recordset

am 19.10.2005 15:53:28 von Brian Ciarcia

Thanks everyone. The GetRows was exactly what I needed.. Thanks for your
help.


*** Sent via Developersdex http://www.developersdex.com ***

Re: asp show specific record from recordset

am 19.10.2005 17:30:13 von rdanjou

I've never used getString so I would not have "contested" your suggestion.
:-)

"McKirahan" wrote in message
news:FqqdnSVdwdyA1cveRVn-qQ@comcast.com...
> "McKirahan" wrote in message
> news:ELKdnXAVPu9n2cveRVn-rQ@comcast.com...
>> "Brian" wrote in message
>> news:1129725796.076861.242890@g14g2000cwa.googlegroups.com.. .
>> > I know this is a weird request, but lets say I create a recordset with
>> > 5 row and 5 columns. How can I, for instance, pull out the record
>> > from row(3) column(2).. I know i can pull from a column by just doing
>> > this, Recordset(2).value, which pulls the record from the 3rd column.
>> > Is there a way to do what I want?
>> >
>>
>> Here's one way:
>>
>> Dim strRSG
>> strRSG = Recordset.getString(2,,"|",vbCrLf)
>> Dim arrRSG
>> arrRSG = Split(strRSG,vbCrLf)
>> Response.Write(Split(arrRSG(2),"|")(1))
>
>
> Raymond's right:
>
> Dim strGET
> strGET = objRST.GetRows(3,0)
> Response.Write(strGET(2,1))
>
> Or some variation thereof.
>
> http://www.w3schools.com/ado/met_rs_getrows.asp
>
>

Re: asp show specific record from recordset

am 19.10.2005 17:34:46 von rdanjou

"Bob Barrows [MVP]" wrote in message
news:uNRGY7K1FHA.3300@TK2MSFTNGP15.phx.gbl...
> I know, it's pedantic, but I'm sure you meant to say: "how do I pull the
> data out of the third field in the fourth record of my recordset?"
>
> Even more pedantic (sorry):
> Recordsets have fields and records. Relational databases have rows and
> columns.

Are you going "Celko" on us Bob?

Besides that, good detailed explanation.
I guess that's what separates the MVPs from us ordinary people. :-)

Re: asp show specific record from recordset

am 19.10.2005 17:53:21 von reb01501

Raymond D'Anjou wrote:
> "Bob Barrows [MVP]" wrote in message
> news:uNRGY7K1FHA.3300@TK2MSFTNGP15.phx.gbl...
>> I know, it's pedantic, but I'm sure you meant to say: "how do I pull
>> the data out of the third field in the fourth record of my
>> recordset?"
>>
>> Even more pedantic (sorry):
>> Recordsets have fields and records. Relational databases have rows
>> and columns.
>
> Are you going "Celko" on us Bob?
>
Heaven forbid! Have you ever seen Celko apologize for being pedantic? :-)

Bob

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.