title: Run SQL Query From VBA
body: <p>I am using this syntax to run a SQL Server 2008 stored procedure from Excel 2013.  Everything executes as it should on one PC, but if I attempt to run it on a second PC it errors out with an </p>
  
  <blockquote>
    <p>OLEDB Connection error</p>
  </blockquote>
  
  <p>Shouldn't since I am hardcoding the servername, username, and password the syntax run w/o a hitch on any PC?</p>
  
  <pre><code>Function RunSQLServerProc()
  Dim con As ADODB.Connection
  Dim cmd As ADODB.Command
  Dim rs As ADODB.Recordset
  Set con = New ADODB.Connection
  Set cmd = New ADODB.Command
  Set rs = New ADODB.Recordset
  con.Open "Provider=SQLOLEDB;Data Source=Server;Initial Catalog=Database;User Id=userid;Password=password;Integrated Security=SSPI;Trusted_Connection=Yes;"
  cmd.ActiveConnection = con
  cmd.CommandText = "TestProc"
  Set rs = cmd.Execute(, , adCmdStoredProc)
  End Function
  </code></pre>