msfz751

Untitled

Jan 19th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Dim con As ADODB.Connection
  3. Dim cmd As ADODB.Command
  4. Dim rs As ADODB.Recordset
  5. Dim par As String
  6. Dim WSP1 As Worksheet
  7.  
  8. Sub connect()
  9.     Set con = New ADODB.Connection
  10.     Set cmd = New ADODB.Command
  11.     Set rs = New ADODB.Recordset
  12.    
  13.     Application.DisplayStatusBar = True
  14.     Application.StatusBar = "Contacting SQL Server..."
  15.    
  16.     ' Remove any values in the cells where we want to put our Stored Procedure's results.
  17.    Dim rngRange As Range
  18.     Set rngRange = Range(Cells(8, 2), Cells(Rows.Count, 1)).EntireRow
  19.     rngRange.ClearContents
  20.    
  21.     ' Log into our SQL Server, and run the Stored Procedure
  22.    con.Open "Provider=SQLOLEDB.1;Data Source=PCSB-SGH220RQTW\SQLPOOL;Initial Catalog=dashboard;Trusted_Connection=Yes"
  23.     cmd.ActiveConnection = con
  24.     Dim prmCustomerID As ADODB.Parameter
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment