|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
os_oa* run exe written in vb6I need to launch an exe application written in VB6 from stored procedure or
trigger. I know I have to use os_oa* but I cannot find any document to help me build one. Many examples that I found have something to do with com but I only have exe. I know this is not the way to go but I was told to do it. Can any one help me by pointing me in the right directions? I know nothing about this so I am learning from scratch for os_oa*. The exe was developed to run silent in the background with no user interface. Search for xp_cmdshell in BOL, it may be useful.
Francesco Anti Show quoteHide quote "UGH" <nospam@noSPam.com> wrote in message news:eRxL9tFaFHA.1368@tk2msftngp13.phx.gbl... >I need to launch an exe application written in VB6 from stored procedure or >trigger. I know I have to use os_oa* but I cannot find any document to help >me build one. Many examples that I found have something to do with com but >I only have exe. I know this is not the way to go but I was told to do it. >Can any one help me by pointing me in the right directions? I know nothing >about this so I am learning from scratch for os_oa*. > > > > The exe was developed to run silent in the background with no user > interface. > > Do you mean sp_oa* ?? If so, here is everything you need:
1. Compile your VB6 class into a DLL. You better have good error handling in it otherwise you risk crashing your SQL Server. 2. Place that DLL into the WIN32 directory on your SQL Server, and REGISTER it on your SQL Server by using RegSvr32.exe 3. Call methods of your VB6 class/dll from any stored procedure, using something like the following (some of the names have been changed to protect the innocent): BEGIN blah blah blah DECLARE @Object int -- holds a reference to your object instantiated from the vb6 class. SET @MethodToCall = 'CalculatePayment(' + @RatePercent + ', ' + @RateIncrease + ', ' + @Months + ', ' + @Fees + ')' --Instantiate an instance of our DataConversion class and put it's reference in @object EXEC sp_OACreate 'Your_VB_Class.DataConversion', @object OUT --Run the CalculatePayment method of our DataConversion class - and place it's output into @Return EXEC sp_OAMethod @object, @MethodToCall, @return OUT -- Destroy the instance of our DataConversion class now that we're done with it. EXEC sp_OADestroy @object blah blah blah END 4. Any time you need to upgrade your VB6 DLL, be sure to Unregister the old one (using RegSvr32.exe... -U), then replace the old DLL with the new one, and then register the new one like in step 2 above. No need to restart your SQL Server. That's it - really quite straight-forward, actually. -HTH Show quoteHide quote "UGH" <nospam@noSPam.com> wrote in message news:eRxL9tFaFHA.1368@tk2msftngp13.phx.gbl... >I need to launch an exe application written in VB6 from stored procedure or >trigger. I know I have to use os_oa* but I cannot find any document to help >me build one. Many examples that I found have something to do with com but >I only have exe. I know this is not the way to go but I was told to do it. >Can any one help me by pointing me in the right directions? I know nothing >about this so I am learning from scratch for os_oa*. > > > > The exe was developed to run silent in the background with no user > interface. > > Hi,
Use the following : EXEC xp_cmdshell 'your vb program.exe' you want to grant the right to execute xp_cmdshell to the SQL login LimitedUser. You'll need an NT account to execute the program. Here's the script: use master go xp_sqlagent_proxy_account N'SET' , N'<mydomain>' , N'<ntuser>' , N'<ntuser's password>' go -- retrieve the proxy account to check that it's correct. xp_sqlagent_proxy_account N'GET' go -- grant database access in master sp_grantdbaccess 'LimitedUser' go grant exec on xp_cmdshell to LimitedUser go Thanks, Tarek ghazali Show quoteHide quote "UGH" <nospam@noSPam.com> wrote in message news:eRxL9tFaFHA.1368@tk2msftngp13.phx.gbl... >I need to launch an exe application written in VB6 from stored procedure or >trigger. I know I have to use os_oa* but I cannot find any document to help >me build one. Many examples that I found have something to do with com but >I only have exe. I know this is not the way to go but I was told to do it. >Can any one help me by pointing me in the right directions? I know nothing >about this so I am learning from scratch for os_oa*. > > > > The exe was developed to run silent in the background with no user > interface. > > |
|||||||||||||||||||||||