How to capture the print of sp using ADOBD or something?

  • Hello friends, exists some friend that have a visual basic script to capture the prints of sp using ADOBD or something?

     

     

    for example

    create proc hello

    as

    begin

    print 'Hello'

    end

     

    i need to build a dll that  capture 'Hello' and show me, thanks for your help,

     

  • I already answered that question for you.

    BTW, what do you mean by show?

    Do you want to have a messagebox? an html (asp, aspx) file? a form?

  • i need to display the print into a  messagebox... thanks

  • Just run the proc you just created (into a recordset)

    in you don't have any records, check the errors collection for your messages, they should be there. Then you'll simply have to concatenate and show them.

  • Friend, Do you have some scritp of  example to do that???

  • No and I don't have .net installed here.

    Err.. in what language did you need this already?

  • i need Only a visual basic code...

    for example

    set objsDB = Server.CreateObject("ADODB.Connection")

    'oConnDB.CursorType = 3; //adOpenStatic

    objsDB.CursorLocation = adUseClient

    objsDB.ConnectionString = AppCacheRead("DSN_OPTIONAL",msUserID,mlSiteID,msSessionID)

    objsDB.Open()

    set oCmd = Server.CreateObject("ADODB.Command")

    oCmd.ActiveConnection = objsDB

     

    oCmd.CommandText = "exec CP_IncidentReassign " & cstr(mlSiteID) & ",'ESP','" & msUserID & "','" & Valor_Bus & "','" & Valor_Bus2 & "'"

    oCmd.CommandType = adCmdText

    set oRS = oCmd.Execute()

    -------------------------------------------------------------------

    but i dont know how to capture the prints of sp.......

     

     

  • after the open statement :

    Dim Er 'As Error

    For Each Er In objsDB.Errors

    MsgBox Er.Description & " : " & Er.Source & " : " & Er.SQLState & " : " & Er.Number

    Next

  • Alas, why this proc i cant capture the print 'hello' ?????????

     

    create proc SP_test

    as

    begin

    select '1'

    print 'hello'

    select '2'

    end

    ----------------------------------------------------------------------

    My visual script

    --------------------------------------------------------------------------

    Set cnn1 = New ADODB.Connection

      cnn1.ConnectionString = "driver={SQL Server};" & _

          "server=" & Trim(server) & ";uid=" & Trim(login) & ";pwd=" & Trim(pwd) & ";database=" & Trim(base)

      

       cnn1.ConnectionTimeout = 120

      cnn1.Open

      

      

       Set reg = New ADODB.Recordset

       Set reg = cnn1.Execute("exec SP_test")

    error:

      

       Dim Err As error

    For Each Err In cnn1.Errors

    MsgBox Err.Description & " : " & Err.Source & " : " & Err.SQLState & " : " & Err.Number

    Next

    cnn1.Close

     

     

  • Play with this :

    Set reg = reg.NextRecordset

    I think that you can access the errors only AFTER the last recordset has been loaded.

  • I tried with that  but it continues displaying nothing...

  • it would surely help if I gave you this :

    CREATE PROCEDURE [dbo].[SPNTest]

    AS

    SET NOCOUNT ON

    Select Id, Name from dbo.SysObjects order by Name

    Print 'Hello World'

    RAISERROR (1, 0, 0)

    SET NOCOUNT OFF

    GO

  • That doesn't work very well.

    I can't find a way to capture the err message..

    Maybe this will get you started (you'll need to translate to vba) :

    Sub test()

    On Error GoTo Gestion

    Dim MyRs As ADODB.Recordset

    Set MyRs = CurrentProject.Connection.Execute("EXEC dbo.SPNTest")

    Set MyRs = MyRs.NextRecordset

    Set MyRs = Nothing

    Exit Sub

    Gestion:

    MsgBox Err.Description

    End Sub

  • Thanks well i must to use a raiserrorr ,well if doesnt exists another option

    ,but that solve in one way my problem , thank you a lot of

    sorry my disturbings .....

Viewing 14 posts - 1 through 13 (of 13 total)

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