How to get the columns in getrows()?

# Thread: How to get the columns in getrows()?

1. Senior Member
Join Date
Dec 1969
Posts
258

## How to get the columns in getrows()?

While using getrows(),how do I dynamically get the number of columns in a sql stmt?<BR>eg. select * from a (where there are 4 columns in table a)<BR>arr = rs.getrows()<BR>Rows = Ubound(arr,2) <BR><BR>This gives me the rows. I dont want to hardcode the number of column in the table. IS there a more clean way to get the columns?<BR><BR>Thanks<BR>Josh

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## RE: How to get the columns in getrows()?

try this<BR><BR>Columns = UBound(arr, 1) + 1 since an array starts from 0 you add 1..i think this is how you do it i still get confused between rows and columns

3. Senior Member
Join Date
Dec 1969
Posts
258

## RE: How to get the columns in getrows()?(more info

arr = RS.getrows()<BR>Rows = Ubound(arr,2)<BR><BR>arr(0,0)----&#062; means 1st row 1st column<BR>arr(0,1)----&#062; means 1st row 2nd column<BR>...<BR>arr(1,0)----&#062; means 2nd row 1st column<BR>arr(1,1)----&#062; means 2nd row 2nd column<BR><BR>But my question is,how can I get the number of columns which is returned in a sql stmt if I do a "select * from a". Yes I can hardcode but I was wondering is there another way to find out?<BR>

4. Prakash Guest

## RE: How to get the columns in getrows()?

do<BR>Response.Write "Recordset filed count: " & rst.Fields.Count<BR><BR>regards<BR>Prakash

5. Senior Member
Join Date
Dec 1969
Posts
258

## RE: How to get the columns in getrows()?

I got 0. Is it because I am doing a * from a. Do I have to write all the column names proably???<BR><BR>I am doing a select * from a...

6. Senior Member
Join Date
Dec 1969
Posts
258

## RE: How to get the columns in getrows()?

I got 0. Is it because I am doing a * from a. Do I have to write all the column names proably???<BR><BR>I am doing a select * from a...

#### Posting Permissions

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