Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column names query 1

Status
Not open for further replies.

evaleah

Programmer
Mar 18, 2003
252
US
Does anyone know of a way to select just the column names from a query?

Thanks,
Eva
 
Yes, though depends.

As you posted this in VBA forum I will assume its through a ado recordset object.

Below is sample code

Code:
Dim rsadoDB as new adodb.recordset
'this assumes cn connection already open 

set rsadodb = cn.execute "Select field1, field2 from mytable"

'return the column name in fields (should be field1 and field2
dim i as integer
for i = 0 to rsadodb.fields.count
debug.print rsadodb.fields(i).name
next i


if its not VBA then please post back.




"I'm living so far beyond my income that we may almost be said to be living apart
 
That was it! I had actually JUST found it and was going to post here, but it was nice to come and find the answer there confirmed.
 

Just to be picky....
Code:
[green]
'return the column name in fields (should be field1 and field2[/green]
dim i as integer
for i = 0 to rsadodb.fields.count [red][b]- 1[/b][/red]
    debug.print rsadodb.fields(i).name
next i

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top