View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bret Bret is offline
external usenet poster
 
Posts: 32
Default SQL CopyFromRecordset

My Excel program is a front end to a SQL backend.
Users run various reports that execute stored procedures in SQL server.
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. The stored procedures are just simple "Select * from" statements.

here is the code that works but has no headers.
myConnection.Open
Set myCommand.ActiveConnection = myConnection
Set myRecordSet.ActiveConnection = myConnection
myCommand.CommandText = strSQL
myCommand.CommandType = adCmdText
myCommand.Execute
myRecordSet.Open myCommand

'Paste to spreadsheet
ThisWorkbook.Worksheets("Report").Range("a2").Copy FromRecordset
myRecordSet

thanks for any help