ExecuteWithResultsAndMessages doesnt return PRINT stmts

  • I'm trying to run a sequence of stored procs using DMO from a VB program, and I want to log the output of all PRINT statements in the stored procs as well as any SQL error messages they might generate, a la Query Analyzer.  The ExecuteWithResultsAndMessages method of the SQL DMO server object returns errors to my VB code just fine, but I don't get the results of any PRINT statements embedded in the stored procs.  What does Query Analyzer use to get ALL output from a stored proc?  Also, everything I can find says to use the ExecuteWithResultsAndMessages2  method rather than ExecuteWithResultsAndMessages; even though I'm using the SQLServer2 object, I don't have the ExecuteWithResultsAndMessages2 method available!  When I try to type the full name (with the 2) in, I get a compile error.  Any light that you can shed would be appreciated!

     

    - Matt

    Kindest Regards,

    Matt Gauch

  • ExecuteWithResultsAndMessages2 is not required but make sure you provide a proper object for the Messages parameter.

    object.ExecuteWithResultsAndMessages( Command , Length , Messages )as QueryResults

    Ex. dmoDB is a Database object

        Dim strMsg As String

       

        dmoDB.ExecuteWithResultsAndMessages "PRINT 'John Jacob Jingle'", , strMsg

       

        MsgBox strMsg

    strMsg will return the message from the PRINT statement. Not it has a preamble to the output of "[Microsoft][ODBC SQL Server Driver][SQL Server]" when you run.

  • I try to run the following JScript code and never see "AAAAAAAAAAAAAA" as a result.

    function bt2Click()

    {

    var sql = "print 'AAAAAAAAAAAAAA'";

    //var msg;

    //var msg = "";

    var msg = "BBBBBBBBBBBBBB";

    //database.ExecuteWithResultsAndMessages(sql, sql.length, msg);

    database.ExecuteWithResultsAndMessages2(sql, msg);

    alert(msg);

    }

    However the JScript code:

    var res = database.ExecuteWithResults(sql);

    works properly.

    Delphi code shows fine result:

    oDatabase.ExecuteWithResultsAndMessages(sql, Length(sql), msg);

    ShowMessage(msg);

    How can i resolve this in JScript?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply