Difference between getrows and getstring

A

Aaron Bertrand - MVP

GetRows() is typically used when you still need to do row-by-row processing,
or you need to refer to certain members in the set individually.

GetString() is useful when you need a formatted string that has simple
determinations for what goes between a "row" and "column" (e.g. not too much
complex iteration or conditional logic, like when alternating row colors for
display)... see one usage here: http://www.aspfaq.com/2482

For more comparison stuff, see http://www.aspfaq.com/2467

A
 
C

Crane Linkledder

Thanks to the both of you. One last question. When using getrows, is it
possible to exclude specific columns?

I am selecting more columns in my SELECT statement than I'd like to display
on screen. How can I filter them out?

Thanks
 
B

Bob Barrows

Crane said:
Thanks to the both of you. One last question. When using getrows, is
it possible to exclude specific columns?
The documentation is here:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdamth02_10.asp

As you will see, you can supply an " ... array of field names or ordinal
position numbers" in the third argument. So if you wanted to only use the
first, third and fifth fields in the recordset, you could do this:

arResults = rs.GetRows(,,array(0,2,4))

The MSDN Library is your friend.

HTH,
Bob Barrows
 
C

Crane Linkledder

It says-
Variant = recordset.GetString(StringFormat, NumRows, ColumnDelimiter,
RowDelimiter, NullExpr)
It does not look like it is possible to filter out columns using getString.
How can I get around this?TIA
 
C

Chris Hohmann

Crane Linkledder said:
I'm sorry. I meant getString. Is this true with getString also?

No, there is no parameter for the GetString method that corresponds to
the Fields parameter in the GetRows method. However, I'll bet
dollars-to-donuts that if you provide the sql statement we can "hide"
the fields you don't need.

HTH
-Chris Hohmann
 
C

Crane Linkledder

Thank you. I was starting to panic.


Here is my statement-

SQL = "SELECT " & users & ".one, " & users & ".two,
"&calendar&".appointmentStart, "&calendar&".appointmentEnd, "&calendar&".ID,
"&calendar&".ownerID, "&calendar&".clientID, " & users & ".userID " &_
"FROM "&calendar&", " & users & " " &_
"WHERE "&users&".userID = "&calendar&".clientID " &_
" AND recurring = '0' ORDER BY appointmentStart"


I am trying to avoid displaying-

calendar&".ownerID "
calendar&".clientID "
users & ".userID "
 
B

Bob Barrows

Crane said:
Thank you. I was starting to panic.


Here is my statement-

SQL = "SELECT " & users & ".one, " & users & ".two,
"&calendar&".appointmentStart, "&calendar&".appointmentEnd,
"&calendar&".ID, "&calendar&".ownerID, "&calendar&".clientID, " &
users & ".userID " &_ "FROM "&calendar&", " & users & " " &_
"WHERE "&users&".userID = "&calendar&".clientID " &_
" AND recurring = '0' ORDER BY appointmentStart"


I am trying to avoid displaying-

calendar&".ownerID "
calendar&".clientID "
users & ".userID "
Why retrieve the fields at all if you don't want to display them?

Are you doing something else with their contents behind the scenes? If so,
you will need to go with the GetRows solution.

Bob Barrows
 
C

Crane Linkledder

Bob Barrows said:
Why retrieve the fields at all if you don't want to display them?

Are you doing something else with their contents behind the scenes? If so,
you will need to go with the GetRows solution.

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


I somehow got it in my head that I needed to select all the columns that I'm
using in my select statement... WHERE column6 = column7

I just removed those and it's working regardless.

Thanks for pointing that out.
 
A

Aaron Bertrand - MVP

I am selecting more columns in my SELECT statement than I'd like to
display
on screen. How can I filter them out?

Drop them from the SELECT? Why are you bothering to select them if you're
not using them?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top