Professional Web Applications Themes

Trigger example to send inserted to printer - Microsoft SQL / MS SQL Server

Will someone please post an example of how to print the inserted (or deleted) record in a trigger to a printer? I cannot make it work. Thanks Wj...

  1. #1

    Default Trigger example to send inserted to printer

    Will someone please post an example of how to print the inserted (or
    deleted) record in a trigger to a printer? I cannot make it work.

    Thanks Wj


    Will Guest

  2. #2

    Default Trigger example to send inserted to printer

    Will,

    I fully agree with Dejan.

    Still if you want to do it, it can be done in a round
    about way. You have to capture all the records from
    inserted and deleted tables into a temp table inside your
    trigger as these tables are not accessible outside the
    trigger.

    Use DTS to out the records of this temp table into a .txt
    file.

    Then use something like this:

    declare
    PrinterName varchar(100),
    Command varchar(100),
    PrintRequestCount int

    set PrinterName = '\\scbdc\pcg laserjet5000'
    print 'There '
    + case printrequestcount
    when 0 then 'are no reports'
    when 1 then 'is 1 report'
    else 'are '+ convert(varchar(3),PrintRequestCount)
    +' reports'
    end
    + ' waiting to be printed.'
    if PrintRequestCount > 0
    begin
    exec master.dbo.xp_cmdshell 'isqlw -SJasper2 -
    dReporting -Usa -Pinsql -ic:\print.sql -oc:\ReportOut.txt'
    set Command = 'copy c:\reportout.txt "'+PrinterName+'"'
    print Command
    exec master.dbo.xp_cmdshell Command
    end

    Like I said before, its not recommended this way.

    Ricky
     
    inserted (or 
    it work. 
    Ricky Guest

  3. #3

    Default Re: Trigger example to send inserted to printer

    What I decided to do is to write a vb.exe application (it's windowless) and
    pass the ID from inserted as 'vb.exe id'. I could write it as a dll but I
    don't know how to call the dll with triggers. I thought it would be just
    simpler to do it with an executable.

    SO now I need to know how to call a executable from within a trigger. I
    understand that it can be done. Do you know how?

    Thanks
    wj


    "Ricky" <state.mn.us> wrote in message
    news:0d3501c35c30$d093f950$gbl... 
    > inserted (or 
    > it work. [/ref]


    Will Guest

  4. #4

    Default Re: Trigger example to send inserted to printer

    So, what do you really thinK?




    "Joe Celko" <edu> wrote in message
    news:phx.gbl... [/ref]
    > printer? <<
    >
    > You are trying to write a 1950's style COBOL program in the 21-st
    > century. What we used to have was a monolithic program with files that
    > were kept in a format which belonged to the host language. Those files
    > has records; SQL does not. All the I/O was in the application and the
    > app and data were blended together.
    >
    > The whole idea of a client/server system is that the back end retrieves
    > the data and the front end does the display -- look up "tiered
    > architectures" somewhere. Also, "kludge" is another good word to know.
    >
    > --CELKO--
    > ===========================
    > Please post DDL, so that people do not have to guess what the keys,
    > constraints, Declarative Referential Integrity, datatypes, etc. in your
    > schema are.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/ref]


    Will Guest

  5. #5

    Default Re: Trigger example to send inserted to printer

    If you don't recommend printing in a trigger. So, how would you justify
    sp_sendmail in a trigger?

    "Dejan Sarka" <si> wrote in
    message news:O%phx.gbl... 
    printing 
    trigger 
    long, 
    >
    >[/ref]


    Will Guest

Similar Threads

  1. Send direclty to printer
    By Fedic in forum Dreamweaver AppDev
    Replies: 2
    Last Post: March 10th, 01:11 PM
  2. Send Doents to Printer
    By Paul in forum ASP
    Replies: 1
    Last Post: August 15th, 10:20 AM
  3. Using Inserted and Deleted tables in Conjunction in a Trigger
    By Mark Simmerman in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: July 9th, 07:41 AM
  4. Send to Printer Option???
    By rideonmidnightrudy webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 8th, 06:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139