Microsoft KB Archive/225042: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
(3 intermediate revisions by the same user not shown)
Line 78: Line 78:
<ol>
<ol>
<li><p>Open a new Active Server Pages (ASP) page in Visual InterDev and paste the following code onto the page:</p>
<li><p>Open a new Active Server Pages (ASP) page in Visual InterDev and paste the following code onto the page:</p>
<pre class="codesample">&lt;%@ Language=VBScript %&gt;
<pre class="codesample"><%@ Language=VBScript %>
&lt;%
<%
         Set cn = Server.CreateObject(&quot;ADODB.Connection&quot;)
         Set cn = Server.CreateObject("ADODB.Connection")
     cn.Open &quot;pubs&quot;,&quot;sa&quot;,&quot;&quot;
     cn.Open "pubs","sa",""
     Set cmd = Server.CreateObject(&quot;ADODB.Command&quot;)
     Set cmd = Server.CreateObject("ADODB.Command")
     Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)  
     Set rs = Server.CreateObject("ADODB.Recordset")  
     cmd.CommandText = &quot;Select * From Authors Select * From Stores Select * From Sales&quot;
     cmd.CommandText = "Select * From Authors Select * From Stores Select * From Sales"
     cmd.CommandType = 1
     cmd.CommandType = 1
     Set cmd.ActiveConnection = cn
     Set cmd.ActiveConnection = cn
         rs.Open cmd
         rs.Open cmd
     Response.Write(rs(0) &amp; &quot;&lt;BR&gt;&quot;)
     Response.Write(rs(0) & "<BR>")
      
      
     GetDBValues  
     GetDBValues  


         Response.Write(rs(0) &amp; &quot;&lt;BR&gt;&quot;)
         Response.Write(rs(0) & "<BR>")
         Response.Write(rs(1) &amp; &quot;&lt;BR&gt;&quot;)
         Response.Write(rs(1) & "<BR>")
      
      
         Set rs = rs.NextRecordset 'Fails on this line
         Set rs = rs.NextRecordset 'Fails on this line
    
    
         Response.Write(&quot;New Recordset after NextRecordset Call&quot; &amp; &quot;&lt;BR&gt;&quot;)
         Response.Write("New Recordset after NextRecordset Call" & "<BR>")
         Response.Write(rs(0) &amp; &quot;&lt;BR&gt;&quot;)
         Response.Write(rs(0) & "<BR>")
         Response.Write(rs(1) &amp; &quot;&lt;BR&gt;&quot;)
         Response.Write(rs(1) & "<BR>")
      
      
   Sub GetDBValues
   Sub GetDBValues
      
      
     Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)
     Set rst = Server.CreateObject("ADODB.Recordset")
     cmd.CommandText = &quot;Select * from stores&quot;
     cmd.CommandText = "Select * from stores"
     cmd.CommandType = 1
     cmd.CommandType = 1
     Set cmd.ActiveConnection = cn
     Set cmd.ActiveConnection = cn


     rst.Open cmd
     rst.Open cmd
     Response.Write(&quot;Opened new recordset&quot; &amp; &quot;&lt;BR&gt;&quot;)
     Response.Write("Opened new recordset" & "<BR>")
   End Sub       
   End Sub       
   %&gt;
   %>


                     </pre></li>
                     </pre></li>
<li>Create a data source name (DSN) called &quot;pubs&quot; that points to the pubs database on SQL Server.</li>
<li>Create a data source name (DSN) called "pubs" that points to the pubs database on SQL Server.</li>
<li>Run the page and the following error appears:
<li>Run the page and the following error appears:
<div class="errormessage">
<div class="errormessage">


'80004005' &quot;Unspecified error&quot;
'80004005' "Unspecified error"


</div></li></ol>
</div></li></ol>

Latest revision as of 13:43, 21 July 2020

Article ID: 225042

Article Last Modified on 10/23/2003



APPLIES TO

  • Microsoft Data Access Components 2.0
  • Microsoft Data Access Components 2.1



This article was previously published under Q225042

SYMPTOMS

Within your MDAC code, you have multiple recordsets with the same recordset object that are created off of the same command and are also pointing to the same connection. The first recordset that is opened contains multiple recordsets within that same object. Before calling NextRecordset on that object, open another Recordset (new recordset object) and point the ActiveConnection property to the same command and connection to which at the other recordset object was pointing. This causes the following error when the Set rs = rs.NextRecordset is executed:

error '80004005' Unspecified error

This error occurs in MDAC 2.0 and MDAC 2.1. It does not occur in MDAC 1.5.

RESOLUTION

Make sure that the ActiveConnection property of the Command object for the first recordset is set only once throughout the page (especially if it contains multiple physical recordsets within the same recordset object) if the same connection is still being used.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in MDAC 2.5.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open a new Active Server Pages (ASP) page in Visual InterDev and paste the following code onto the page:

    <%@ Language=VBScript %>
    <%
            Set cn = Server.CreateObject("ADODB.Connection")
        cn.Open "pubs","sa",""
        Set cmd = Server.CreateObject("ADODB.Command")
        Set rs = Server.CreateObject("ADODB.Recordset") 
        cmd.CommandText = "Select * From Authors Select * From Stores Select * From Sales"
        cmd.CommandType = 1
        Set cmd.ActiveConnection = cn
            rs.Open cmd
        Response.Write(rs(0) & "<BR>")
        
        GetDBValues 
    
            Response.Write(rs(0) & "<BR>")
            Response.Write(rs(1) & "<BR>")
        
            Set rs = rs.NextRecordset 'Fails on this line
       
            Response.Write("New Recordset after NextRecordset Call" & "<BR>")
            Response.Write(rs(0) & "<BR>")
            Response.Write(rs(1) & "<BR>")
        
      Sub GetDBValues
        
        Set rst = Server.CreateObject("ADODB.Recordset")
        cmd.CommandText = "Select * from stores" 
        cmd.CommandType = 1
        Set cmd.ActiveConnection = cn
    
        rst.Open cmd
        Response.Write("Opened new recordset" & "<BR>")
      End Sub       
      %> 
    
                        
  2. Create a data source name (DSN) called "pubs" that points to the pubs database on SQL Server.
  3. Run the page and the following error appears:

    '80004005' "Unspecified error"


Keywords: kbbug kbmdac250fix KB225042