Microsoft KB Archive/279514

= BUG: ExecuteWithResultsAndMessages2 Does Not Return Results =

Article ID: 279514

Article Last Modified on 11/17/2003

-

APPLIES TO


 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q279514



BUG #: 17969 (SQLBUG_65)

BUG #: 39552 (SQLBUG_70)

BUG #: 235353 (SHILOH)



SYMPTOMS
When called from Microsoft Visual Basic Script (VBScript), the ExecuteWithResultsAndMessages2 method does not return results. Instead, it generates a run-time error similar to the following:

Windows Script Host

Error: Type mismatch: 'db.ExecuteWithResultsAndMessages2'

Code: 800A000D

Source: Microsoft VBScript runtime error

The ExecuteWithResultsAndMessages2 method works correctly within Visual Basic when the variable is defined as a string.



CAUSE
The ExecuteWithResultsAndMessages2 method executes a Transact-SQL command batch, returns batch result sets in a QueryResults object, and captures messages raised as part of command batch execution. A string is used to return the message output, but the VB script uses a variant data type. The mismatch between the string and variant data types causes the type mismatch error.



STATUS
Microsoft has confirmed this to be a problem in SQL Server 6.5.

Microsoft has confirmed this to be a problem in SQL Server 7.0.

Microsoft has confirmed this to be a problem in SQL Server 2000.



MORE INFORMATION
To reproduce the problem, use the following code, replacing the server name, login id, and password appropriately: Option Explicit Dim objSqlServer Dim objDatabase Dim objTable Dim objQueryResults Dim strMessages Set objSqlServer = WScript.CreateObject(&quot;SQLDMO.SQLServer&quot;) Call objSqlServer.Connect(&quot;server name&quot;,&quot;login id&quot;,&quot;password&quot;) Set objDatabase = objSqlServer(&quot;pubs&quot;) WScript.Echo(&quot;Enter Call ExecuteWithResultsAndMessage2&quot;) strMessages = &quot;&quot; Set objQueryResults = objDatabase.ExecuteWithResultsAndMessages2(&quot;DBCC CHECKALLOC('pubs')&quot;,strMessages) WScript.Echo(strMessages) Set objTable = objDatabase.Tables(&quot;titles&quot;) strMessages = objTable.CheckTable WScript.Echo(&quot;*&quot; & strMessages) WScript.Echo(&quot;Exit Call ExecuteWithResultsAndMessages2&quot;) WScript.Quit(1)

Additional query words: DMO SQL-DMO

Keywords: kbbug kbpending KB279514

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.