title: ADODB.Connection InfoMessage Event never get's fired
body: <p>I post this as new question because the answers in post <a href="https://stackoverflow.com/questions/51327395/execute-sql-server-stored-procedure-from-vba-and-retrieve-all-messages-and-resul">Execute SQL Server stored procedure from VBA and retrieve all messages and result sets</a> didn't solve my problem.</p>
  <p>I use MS Access as frontend to SQL Server and would like to get progress messages back from long running multi-statement SQL procedures, but the InfoMessage event never get's fired. I put <code>Print</code> and <code>RaiseError</code> statements with different severity levels in my stored procedure. Also tried to execute a command object based on the connection, and different OLDDB providers (SQLNCLI10, SQLNCLI11, MSOLEDBSQL, SQLOLEDB)</p>
  <p>The ExecuteComplete event gets fired correctly when the sql procedure ends. The pError Parameter is set to &quot;Executing 1st statement ...&quot;, and - surprisingly - the Connection.Errors collection contains three errors: &quot;Executing 1st statement ...&quot;, &quot;Now for a print statement&quot; and &quot;Executing 3rd statement ...&quot;</p>
  <p>Here is my SQL Code:</p>
  <pre class="lang-sql prettyprint-override"><code>ALTER PROCEDURE TestCommunication 
  AS
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
  
      -- Insert statements for procedure here
      RAISERROR('Executing 1st statement ...', 1, 1) WITH NOWAIT
      WAITFOR DELAY '00:00:05'
  
      RAISERROR('Executing 2nd statement ...', 10, 10) WITH NOWAIT
      WAITFOR DELAY '00:00:05'
  
      PRINT 'Now for a Print-statement!'
      WAITFOR DELAY '00:00:03'
  
      RAISERROR('Executing 3rd statement ...', 16, 16) WITH NOWAIT
      WAITFOR DELAY '00:00:05'
  
      RAISERROR('Completing ...', 16, 10) WITH NOWAIT
  END
  GO
  </code></pre>
  <p>And that's my VBA code:</p>
  <pre class="lang-vb prettyprint-override"><code>Option Compare Database
  
  Private WithEvents conn As ADODB.Connection
  
  Private Sub conn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As ADODB.Connection)
      Debug.Print &quot;Execution ended&quot;
  End Sub
  
  Private Sub conn_InfoMessage(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
      Debug.Print pError.Description
  End Sub
  
  Public Sub RunQuery(strQuery As String)
  
      Set conn = New ADODB.Connection
      conn.ConnectionString = getADODBConnectionString        'Provider=SQLOLEDB;Server=adgpcr.res2.loc.lan.at;Database=CostDB;Integrated Security=SSPI;APP=CostDB;
      conn.Open
      conn.Execute strQuery, , adExecuteNoRecords + adAsyncExecute
  
  End Sub
  </code></pre>
  <pre class="lang-vb prettyprint-override"><code>Public Sub TestMessages()
      
      Set o = New ADODBQuery    'ADODBQuery is the name of the class above
      o.RunQuery &quot;dbo.TestCommunication&quot;
  
  End Sub
  
  </code></pre>
  <p>As recommended by Erik A I added functionality to run the stored procedure through a command object:</p>
  <pre><code>Public Sub RunProcedure(strProcedureName As String)
  
      Set conn = New ADODB.Connection
      conn.ConnectionString = getADODBConnectionString
      conn.Open
      
      Dim cmd As ADODB.Command
      Set cmd = New ADODB.Command
      cmd.CommandType = adCmdStoredProc
      cmd.CommandText = strProcedureName
      cmd.ActiveConnection = conn
      
      cmd.Execute , , adExecuteNoRecords + adAsyncExecute
  
  End Sub
  </code></pre>
  <p>Same result as executing the stored procedure from the connection object.</p>
  <p>Interesting fact: when omitting the options adExecuteNoRecords + adAsyncExecute the ExecuteComplete event is fired immediately (expected) and afterwards the InfoMessage event is fired once (!) with pError and the Errors collection of the connection object set to the first RAISERROR message!?!</p>
  <p>Any comments on what I'm missing?</p>