August 14, 2012 at 9:06 am
We need to execute a VB.NET (2010) executable from SQL (2005).
Is this possible, and what is the best way to do this?
August 14, 2012 at 9:30 am
N11689 (8/14/2012)
We need to execute a VB.NET (2010) executable from SQL (2005).Is this possible, and what is the best way to do this?
I guess this might work: -
EXEC master..xp_CMDShell 'c:yourFile.exe'
August 14, 2012 at 10:05 am
It should be noted that xp_cmdshell is disableb by default in SQL Server (since 2005) and for good reason. Consider carefully before enabling it the security implications. Do you want all sysadmins to be able to interact with the cmd shell on your server?
Resist the urge to turn your SQL Server into an application server. Ask yourself it you really need to execute an app from within T-SQL. From my perspective a design that requires that T-SQL must have access to interact with the file system raises several huge red flags. Another way to do this would be to create a SQL Agent job with a CmdExec step that runs the executable and then start the job from T-SQL using msdb.dbo.sp_start_job (note that sp_start_job is asynchronous).
Ultimately my preferred way to do something like this would be to refactor the T-SQL into two stored procs, a before and after, split at the point where you would call the app. Then using PowerShell, SSIS, C# or some other app development language call the before proc, then call your VB.net executable, then call the after proc.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
August 14, 2012 at 11:36 am
From what I have 'googled', I don't think we want to use xp_cmdshell.
What about SQL CLR? Can you call a vb.net exe (not dll) using an SQL Assembly?
August 14, 2012 at 11:43 am
N11689 (8/14/2012)
From what I have 'googled', I don't think we want to use xp_cmdshell.What about SQL CLR? Can you call a vb.net exe (not dll) using an SQL Assembly?
Sure, but I think you'll need to mark the assembly UNSAFE which is a red flag in and of itself. Again, ask yourself why you're in this spot. My recommendation is to refactor your process such that you do not need to call an executable directly from T-SQL. If you must, see my earlier post on how to accomplish it indirectly using SQL Agent.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
August 14, 2012 at 12:10 pm
We have a new app that needs to automatically create a pdf and email it.
We will be writing a new Crystal Report that will call a sql stored procedure that contains the data necessary to create this .pdf file.
We have an existing vb.net program that uses SAP Crystal Reports' object to generate and output a report (using the Crystal for .NET methods and properties).
We want our app to call this vb.net executable via SQL.
Just trying to find the best approach for this.
August 14, 2012 at 12:32 pm
N11689 (8/14/2012)
We have a new app that needs to automatically create a pdf and email it.We will be writing a new Crystal Report that will call a sql stored procedure that contains the data necessary to create this .pdf file.
We have an existing vb.net program that uses SAP Crystal Reports' object to generate and output a report (using the Crystal for .NET methods and properties).
We want our app to call this vb.net executable via SQL.
Just trying to find the best approach for this.
My preferred approach would be to have your app call the vb.net exe directly, i.e, leave SQL out of the report-generation stack...else use SQL Agent.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
August 14, 2012 at 12:46 pm
Our app resides on a different server than the vb.net exe. The vb.net exe is on the sql server.
I'll take this info you've provided and bring it to the group and see how we will proceed.
August 14, 2012 at 1:06 pm
You can execute a vb.net app from a network location. If you were to post the vb.net app on a file server where all people who needed it could reach it they could execute it from there.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy