Excel 2016 VBA OLE SQL connection help

Excel 2016 VBA to create an OLE connection to a sql 2014 db and then execute a stored procedure returning the results starting cell A1 on sheet :Stored_Proc_Data.
Server & instance is QGZZZ\MYINSTANCE db is data
The SP has a parameter taken from a cell in the spreadsheet
Here is what I have
Sub Macro1()
'
Sheets("Stored_Proc_Data").Select
Range("A1").Select
oConn.Provider = "sqloledb"
oConn.Open "Data Source=QGZZZ\MYINSTANCE;Database=data;Uid=ABC;Pwd=DEF;"
.CommandText = "EXECUTE PROD.FINANCIAL_STATEMENTS '" & range("Parameters!G5").Value & "'"
ActiveWorkbook.RefreshAll
End Sub

Can someone please give me an example

0
edit delete
are you sure?
asked Richard

0 answers

Post an answer but please log in first

Post Answer
  1. Please log in to post answer

Similar Questions

Tagsfor this question

Forumall questions