View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
AA2e72E AA2e72E is offline
external usenet poster
 
Posts: 400
Default SQL CopyFromRecordset

"Bret" wrote:
My question is I use the "copyfromrecordset" code to autofill the returning
recordsets into a worksheet however they dont return the column headers.
How do I get the column headers either from VBA Excel or from the SQL stored
procedures.


I am sure that I have seen an example in the Excel help files that has your
answer.
Try this:

for each fld in myRecordSet.Fields
name = fld.Name
.... code
next

where code is the Excel VBA code for writing each name to successive columns
on Row 1; I assume you can come up with the actual code.