title: Particular query causes ADO Recordset to fail with E_FAIL
body: <p>i'm trying to run (two) queries against SQL Server 2005 using ADO:</p>
  
  <pre><code>SELECT
     sp.nt_username AS NTUsername,
     sp.hostname AS HostName
  FROM sys.dm_tran_locks tl
     INNER JOIN master.dbo.sysprocesses sp
     ON tl.request_session_id = sp.spid
  WHERE tl.resource_type = N'APPLICATION'
  AND tl.resource_database_id = (
         SELECT dbid
         FROM master.dbo.sysprocesses
         WHERE spid = @@spid)
  </code></pre>
  
  <p>and the SQL Server 2000 compatible version:</p>
  
  <pre><code>SELECT
     sp.nt_username AS NTUsername,
     sp.hostname AS HostName
  FROM master.dbo.syslockinfo sli
     INNER JOIN master.dbo.sysprocesses sp
     ON sli.req_spid = sp.spid
  WHERE rsc_type = 10 --10=Appliction
  AND rsc_dbid = (
     SELECT dbid
     FROM master.dbo.sysprocesses
     WHERE spid = @@spid)
  </code></pre>
  
  <p>The query <em>executes</em> fine:</p>
  
  <pre><code>IRecordset rs =new Recordset();
  rs.CursorLocation = adUseClient; //the default for a Recordset is adUseServer (Connection.Execute's default is adUseClient)
  rs.CursorType := adOpenForwardOnly; //the default
  rs.Open(szQuery, conn.ConnectionObject,
         adOpenForwardOnly, //CursorType
         adLockReadOnly, //LockType
         adCmdText);
  </code></pre>
  
  <p>But then <strong><em>checking</em></strong> the status of <code>BOF</code> or <code>EOF</code>:</p>
  
  <pre><code>if (rs.EOF) then
  </code></pre>
  
  <p>triggers an exception:</p>
  
  <ul>
  <li>HRESULT: 0x80004005 (Unspecified error)</li>
  <li>Error message: "Data provider or other service returned an E_FAIL status"</li>
  </ul>
  
  <p>What is about this query that causes ADO to fail so miserably?</p>
  
  <hr>
  
  <p><strong>Note</strong>: There really <strong><em>is</em></strong> a matching row:</p>
  
  <p><img src="https://i.stack.imgur.com/MvCb4.png" alt="enter image description here"></p>
  
  <p>The <code>provider</code> i'm using in the connection string is <code>Provider=SQLOLEDB</code>.</p>
  
  <p>Bonus Chatter:</p>
  
  <blockquote>
    <h2>sysprocesses</h2>
  
  <pre><code>  nt_username nchar(128)
    hostname    nchar(128)
  </code></pre>
  </blockquote>
  
  <p>and querying for both - but one at a time - works, e.g.:</p>
  
  <pre><code>SELECT
     sp.nt_username AS NTUsername
  </code></pre>
  
  <p>and </p>
  
  <pre><code>SELECT
     sp.hostname AS HostName
  </code></pre>
  
  <p>work. Querying for both fail.</p>