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 :StoredProcData. 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("StoredProcData").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 login first

Post Answer
  1. Please login to post answer

Similar Questions

Tagsfor this question

Forumall questions