Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Dim con As ADODB.Connection
- Dim cmd As ADODB.Command
- Dim rs As ADODB.Recordset
- Dim par As String
- Dim WSP1 As Worksheet
- Sub connect()
- Set con = New ADODB.Connection
- Set cmd = New ADODB.Command
- Set rs = New ADODB.Recordset
- Application.DisplayStatusBar = True
- Application.StatusBar = "Contacting SQL Server..."
- ' Remove any values in the cells where we want to put our Stored Procedure's results.
- Dim rngRange As Range
- Set rngRange = Range(Cells(8, 2), Cells(Rows.Count, 1)).EntireRow
- rngRange.ClearContents
- ' Log into our SQL Server, and run the Stored Procedure
- con.Open "Provider=SQLOLEDB.1;Data Source=PCSB-SGH220RQTW\SQLPOOL;Initial Catalog=dashboard;Trusted_Connection=Yes"
- cmd.ActiveConnection = con
- Dim prmCustomerID As ADODB.Parameter
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment