ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2007 AND Retrieving Data from Stored Procedure on SQL Exp 20 (https://www.excelbanter.com/excel-programming/400805-excel-2007-retrieving-data-stored-procedure-sql-exp-20-a.html)

SkyEyes

Excel 2007 AND Retrieving Data from Stored Procedure on SQL Exp 20
 
Currently have some code that when I pass through a select * on a dbo.tbl it
the code retrieves all the table data and places back on sheet1. When I pass
through the stored procedure, it retrieves nothing back. If we run the
stored procedure which is a select of 5 tables, it retrieves the data back.

Any ideas or assistance would be great. See code below.

Sub GetData()

Dim c As ADODB.Connection
Dim rsPubs As ADODB.Recordset

Set c = New ADODB.Connection
Set rsPubs = New ADODB.Recordset

c.Open "DSN=Portfolio"

With rsPubs
.ActiveConnection = c


rsPubs.Open "dbo.sp_getstaffinventory"

Sheet1.Range("A1").CopyFromRecordset rsPubs

.Close

End With

c.Close
Set c = Nothing

End Sub


All times are GMT +1. The time now is 07:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com