Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Display a Recordset in Excel

Hey everyone, I just found this board. I wrote some VBA
to query my SQL Server into a recordset, but I don't know
how to display that recordset on my Excel spreadsheet.
The recordset is full, so how do I put that into Excel?
Here is the Last few lines of my code:

'Create Recordset
rstIVSLH.CursorType = adOpenForwardOnly
rstIVSLH.LockType = adLockReadOnly
rstIVSLH.CursorLocation = adUseClient
Set rstIVSLH = conSQLSERVERConnection.Execute(strSQL)

'ActiveSheet.Rows(3) = rstIVSLH.Fields ???????????????????
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Display a Recordset in Excel

ActiveSheet.Range("A3").CopyFromRecordSet rstIVSLH

Regards,
Tom Ogilvy


"Alex A" wrote in message
...
Hey everyone, I just found this board. I wrote some VBA
to query my SQL Server into a recordset, but I don't know
how to display that recordset on my Excel spreadsheet.
The recordset is full, so how do I put that into Excel?
Here is the Last few lines of my code:

'Create Recordset
rstIVSLH.CursorType = adOpenForwardOnly
rstIVSLH.LockType = adLockReadOnly
rstIVSLH.CursorLocation = adUseClient
Set rstIVSLH = conSQLSERVERConnection.Execute(strSQL)

'ActiveSheet.Rows(3) = rstIVSLH.Fields ???????????????????
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Display a Recordset in Excel

Awesome! Thanks. You're Kung foo is the best.
Alex.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Display the Header??


Tom, or anyone...
Along with this solution is there a way to return the
Header too, meaning the column names for the rows
returned?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Display the Header??

Dim TargetRange as Range
set Target.Range = ActiveSheet.Range("A3")
For intColIndex = 0 To rs.Fields.Count - 1 ' the field names
TargetRange.Offset(0, intColIndex). _
Value = rstIVSLH.Fields(intColIndex).Name
Next
TargetRange.Offset(1, 0).CopyFromRecordset _
rstIVSLH ' the recordset data

--
Regards,
Tom Ogilvy



"Alex" wrote in message
...

Tom, or anyone...
Along with this solution is there a way to return the
Header too, meaning the column names for the rows
returned?





  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Display the Header??

That's awesome man. Thanks again. You have showed me
the way to Yellow Belt in Kung VBA Foo. :}

Take Care,
Alex.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2000 - VBA - Stop recordset Data from auto converting Matt. Excel Programming 2 September 25th 03 01:22 PM
Excel 2000 VBA recordset manipulation Matt. Excel Programming 2 September 16th 03 03:59 PM
Recordset Stephan Kassanke Excel Programming 0 September 10th 03 04:45 PM
Recordset Opening Excel File Seth[_3_] Excel Programming 0 August 1st 03 01:52 PM
open range (within workbook) as ado recordset - excel vba S. Daum Excel Programming 0 July 25th 03 04:45 PM


All times are GMT +1. The time now is 10:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"