Microsoft KB Archive/301437

= PRB: Recordset DTC Error with Empty Recordset =

Article ID: 301437

Article Last Modified on 2/13/2002

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q301437



SYMPTOMS
When you use the Visual InterDev 6.0 Recordset Design-Time Control (DTC), if you view the Active Server Pages (ASP) page in a Web browser, you may receive one the following error messages:

ADODB.Recordset error '800a0e78'

The operation requested by the application is not allowed if the object is closed.

/Project20/_ScriptLibrary/Recordset.ASP, line xxx

-or-

ADODB.Recordset (0x800a0e78)

Operation is not allowed when the object is closed.

//_ScriptLibrary/Recordset.ASP, line 762

Note that the line number reference in the preceding error may differ according to different versions of Script Library.



CAUSE
This error is returned to the browser when you try to run a SQL statement that does not return any records. For example, SQL clauses such as INSERT, UPDATE, DELETE, and/or stored procedures that do not return values may generate one of the above-mentioned error messages.



RESOLUTION
There are two possible workarounds to this behavior:   Manually code the necessary ActiveX Data Objects (ADO) code to run the SQL statement. This allows a SQL statement that may return an empty recordset to be executed, such as a SQL UPDATE, INSERT, or DELETE statement. For example, the following code adds a value to a field in the specified database: <% Set oConn = Server.CreateObject(&quot;ADODB.Connection&quot;) oConn.Open &quot;PROVIDER=SQLOLEDB;DATA SOURCE= ;&quot; & _ &quot;UID=sa;PWD=;DATABASE= &quot; oConn.Execute(&quot;INSERT INTO VALUES &quot;) %> Note that you must modify this code so that it reflects the correct information for the specific server.  Use a Data Command to run the SQL statement. For example:  Add a Data Connection to a Visual InterDev project, and point it to a database. From the Project menu, click Add Data Command.  On the General tab, click SQL Statement, and add the following SQL statement: INSERT INTO tblTest (fldTest) VALUES (101); Note that you may need to modify the preceding statement to conform to the table and field names of your database. Click OK after you add the SQL statement.  Add a new ASP page to your project.</li>  Add the following code to the ASP page: <% Set DE = Server.CreateObject(&quot;DERuntime.DERuntime&quot;) DE.Init(Application(&quot;DE&quot;)) DE.Command1 %>                       </li> From the View menu, click View In Browser. If you are prompted to save the ASP file, click OK. The information will be added to the database.</li></ol> </li></ul>

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> Add a Data Connection to a Visual InterDev project, and point it to a database.</li> Add a new ASP page to your project.</li> Add a Recordset DTC to the ASP page. Make sure that the Connection property is set to the Data Connection that you created in the first step.</li> Right-click the Recordset DTC, and then click Properties.</li>  On the General tab, click SQL Statement, and add the following SQL statement: INSERT INTO tblTest (fldTest) VALUES (101); Note that you may need to modify the preceding statement to conform to the table and field names of your database. Click Close after you add the SQL statement. </li> From the View menu, click View In Browser. If you are prompted to save the ASP file, click OK. You receive one of the above-mentioned error messages.</li></ol>

<div class="references_section">