title: SQL Server 2005 running stored procedure from Excel (VBA)
body: <p>I am trying to run a stored procedure on my SQL server.
  I think the connection type is 'ODBC', but I am unsure, I am trying the below:</p>
  
  <pre class="lang-vb prettyprint-override"><code>'Declare some variables
  Dim cnn As ADODB.Connection
  Dim cmd As ADODB.Command
  Dim strSQL As String
  Dim gway As String
  
  'Create a new Connection object
  Set cnn = New ADODB.Connection
  
  'Set the connection string
  cnn.ConnectionString = connectionString 'See http://connectionstrings.com if you need help on building this string for your database!
  
  'Create a new Command object
  Set cmd = New ADODB.Command
  'Associate the command with the connection
  'Open the Connection to the database
  cnn.Open
  cmd.ActiveConnection = cnn
  
  
  VARIABLE= "param"
  strSQL = "EXECUTE dbo.NAMEWASHERE '" &amp; VARIABLE &amp; "';"
  
  
  
  cmd.Execute strSQL
  
  'Close the connection again
  cnn.Close
  </code></pre>
  
  <p>When I try to run this I recieve the error: 
  Run-time error '3709';</p>
  
  <p>Requested operation requires an OLE DB Session object, which is not supported by the current provider.</p>
  
  <p>I am sure I am just getting my connection type wrong somewhere, but could anybody help me out?</p>
  
  <p>To confirm, I'm trying to connect via ODBC to an SQLServer2005, via Excel VBA (2003)</p>
  
  <p>Many thanks.</p>
  
  <p><strong>UPDATE WITH FIX:</strong> You must open the connection before using ".ActiveConnection = """. I have editted the original code to show this change.</p>