title: Run Stored Procedure in SQL database from Access VBA without windows authentication
body: <p>I am trying to run a stored procedure (using Access VBA) in the SQL database. I can find a few examples of this on SO and on other sites but what I am unable to find is connection string where I can provide my login details as windows authentication won't work because I have to use a different user to connect to SQL database</p>
  
  <p>Here is what I have tried so far (got this from one of the post in SO, unfortunately, I can't find the post anymore):</p>
  
  <pre><code>Sub RunSQLProc()
      Dim cdb As DAO.Database, qdf As DAO.QueryDef
      Set cdb = CurrentDb
      Set qdf = cdb.CreateQueryDef("")
      qdf.Connect = "ODBC;" &amp; _
              "Driver=SQL Server;" &amp; _
              "Server=myServer;" &amp; _
              "Database=myDatabase;" &amp; _
              "UID=myUsername;" &amp; _
              "PWD=myPassword;" &amp; _
              "Trusted_Connection=yes;"
  '            "Driver={SQL Server Native Client 11.0};" &amp; _
  '            "MARS Connection=True;"
      qdf.SQL = "SQLStroedProcedure;"
      qdf.ReturnsRecords = False
      qdf.Execute dbFailOnError   '&lt;-- this line throws the error
      Set qdf = Nothing
      Set cdb = Nothing
  End Sub
  </code></pre>
  
  <p>On <code>qdf.Execute dbFailOnError</code> line, I get the following error:</p>
  
  <blockquote>
    <p>Run-time error '3151':
    ODBC--connection to 'SQL ServermyServer'failed.</p>
  </blockquote>
  
  <p>I have managed to connect to the SQL database and run the stored procedure through <strong>SQL Server Management Studio</strong>. This tells me that the details in my connection string are correct (although I haven't provided the actual details here) but I suspect there is an issue with my connection string. </p>
  
  <p>Happy to provide more details. Any help is much appreciated, thanks </p>
  
  <p>P.S. Apologies for my lack of knowledge in Access. I just don't use it very often</p>