April 22, 2005 at 2:36 pm
Hi all,
I have created a small VB application that does nothing but print out a Crystal Report. There is no user interface. I can call the program from the command prompt and the report goes straight to the printer, with all dialogs suppressed. I try using exactly the same line with xp_cmdshell:
xp_cmdshell '"D:\Program Files\Solomon\ReportPrint"'
...and the application starts and hangs. I see the application in Windows Task Manager, but it never completes. I have to manually stop the process.
Based on some forum research, I tried to call the executable from a SQL Server Agent job. You guessed it...same results...job continues executing until I manually stop the process.
Any ideas on this? Any help would be most appreciated...!
Bill King, MCSD
April 22, 2005 at 2:48 pm
I have learned the hard what that exe files should not be called from xp_cmdshell.
April 22, 2005 at 3:11 pm
So, the program does not require *any* user interaction and terminates after it has printed its' stuff? What about a DTS package with Execute Win32 task (I think it is called so) ?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
April 22, 2005 at 3:19 pm
OMG...
Execute Process Task...
...and it worked like a charm!!! Thanks so much!
Bill King, MCSD
April 25, 2005 at 9:15 am
OK, new twist...
I need to be able to call this DTS package from T-SQL, specifically a trigger (so that I can automatically print the report when a specific field on the target table is updated). Can I call a DTS package from T-SQL?
Bill King, MCSD
April 26, 2005 at 5:26 am
I have not much experience with DTS. You might find something useful here http://www.sqldts.com
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
April 26, 2005 at 6:06 am
If you can't find anything on http://www.sqldts.com try this.... Schedule the DTS package so that it creates a SQL job for you and then make sure that you disable or delete the schedule. You should now have a job (without a schedule).
From within the trigger, execute msdb..sp_start_job <job name>.
It's a bit awkward and not very pretty but it should work.
Karl
April 26, 2005 at 7:51 am
>>From within the trigger, execute msdb..sp_start_job <job name>.<<
Please do not do that, because jobs are not re-entrant! In other words when you try start a job from a trigger if the trigger is fired befor the job finished it won't run again. You will have to consider other avenues like:
1. create a stored proc that uses sp_OA* procedures to launch the DTS
OR
2. (this is what I would do) Create a table that is polled by a job on the trigger insert the necessary information in that table and from the job read what you need and mark the records with a done flag when the job finishes.
hth
* Noel
April 26, 2005 at 8:01 am
Yikes!
Yes, yes - Listen to Noel.
Do NOT place a printing operation inside a trigger! Never ever! Do not ever ever place anything inside a trigger that shouldn't be there. That includes printing, mailing, calling grandma, anything 'external' at all..
Go with Noel's 2 nd suggestion instead.. (not the 1st, that's not too safe either)
/Kenneth
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply