another (different) GetRows question

# Thread: another (different) GetRows question

1. Senior Member
Join Date
Dec 1969
Posts
156

## another (different) GetRows question

I think I know the answer (no) but..i&#039;ll ask anyway.<BR><BR>If I do something like<BR><BR>strSQL = "SELECT * from table"<BR>objRec.Open strSQL, objCon, adOpenStatic<BR>thisVar = objRec.GetRows()<BR><BR>Is there some super-slick way to have GetRows include the column names with my data?<BR><BR>The answer is no, isn&#039;t it?<BR><BR>C&#039;mon...prove me wrong!!!<BR><BR>Thanks!<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## No. <eom>

.

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Welllllll....

&#060;%<BR>...<BR>RS.Open ...<BR>allRows = RS.GetRows()<BR><BR>ReDim Preserve allRows( UBound(allRows,1), UBound(allRows,2)+1 )<BR>namerow = UBound(allRows,2) &#039; new upper bound<BR><BR>For col = 0 To UBound(allRows,1)<BR> allRows(col,namerow) = RS.Fields(col).Name<BR>Next<BR><BR>...<BR>%&#062;< BR><BR>??? Puts the names in the *last* row of the array, but what does that matter?<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
156

## what if there were only one row?

then (0,0) would correlate with (1,0)<BR><BR>yes?<BR><BR>This might work.

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## Huh?

What difference does the number of rows make???<BR><BR>Read what I wrote again. No matter *how* many rows there are, I add one more and then put the column names into the added row.<BR><BR>So, now, the *USER* of that array can do:<BR><BR>&#060;% <BR>maxCol = UBound(allrows,1)<BR>maxRow = UBound(allrows,2)<BR><BR>&#039; column names<BR>Response.Write "&#060;TABLE Border=1&#062;&#060;TR&#062;" & vbNewLine<BR>For col = 0 To maxCol<BR> Response.Write "&#060;TH&#062;" & allrows(col,maxRow) & "&#060;/TH&#062;"<BR>Next<BR>Response.Write "&#060;/TR&#062;" & vbNewLine<BR>&#039; all the data, no matter how much (or little)<BR>For row = 0 To maxRow-1 &#039; don&#039;t do the names row again!<BR> Response.Write "&#060;TR&#062;" & vbNewLine<BR> For col = 0 To maxCol<BR> Response.Write "&#060;TD&#062;" & allrows(col,row) & "&#060;/TD&#062;"<BR> Next<BR> Response.Write "&#060;/TR&#062;" & vbNewLine<BR>Next<BR>Response.Write "&#060;/TABLE&#062;" & vbNewLine<BR>%&#062;<BR><BR>Presto. What matters it how many rows?<BR><BR>************************************* ***********<BR><BR>&#062; then (0,0) would correlate with (1,0)<BR><BR>DOUBLE HUH. What *are* you talking about?<BR><BR>(0,0) is the first row, first column<BR>(1,0) is the first row, second column<BR><BR>In what way, other than being in the same row, do they correlate?<BR><BR>

#### Posting Permissions

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