VB and SQL-agent job-history

  • Hi,

    I want to run a vb-application that gathres statistical info of

    sql-server-databases.

    The application works fine, but I would like to add information (job-log) to

    the sql-job that runs my application.

    This job has one step per screened server/database and the step contains the

    CMDEXEC "vbappl.exe" /server /database.

    My application sets the DOS-errorlevel variable. This is mentioned in the

    jobs jobhistory.

    What's the simplest way to put extra stuff in my job-history knowing I have

    no explicit connection to the server the sql-agent runs on.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • I think you'll have to update sysjobhistory, I know of no built in proc to do it (though it might be there somewhere!) Not sure I'm thrilled with the idea, but I guess no reason not to do it. Typically I have my apps write to a separate table or a text file for status info.

    Andy

  • Building on this I got it to work in VB6 with the folowing code :

    'declaration STDERR-file

    Dim FileSysSTDERR As FileSystemObject

    Set FileSysSTDERR = New FileSystemObject

    'get STDERR-data

    Set Targetfile = FileSysSTDERR.GetStandardStream(StdErr)

    If Targetfile Is Nothing Then

    'Get STDOUT-data

    Set Targetfile = FileSysSTDERR.GetStandardStream(StdOut)

    End If

    'Write to STDERR/STDOUT

    Targetfile.Write "-- MyAppl message : " & CStr(Err.Number) & " " &

    Err.Description & " ErrorSource: " & Err.Source

    This works smoothly when executed by SQL-Agent. (it generates an error when

    launchted by a .BAT-file and NO 1> or 2> are mentioned)

    Jobi

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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