Friday, January 27, 2012

Class not registered sp_OACreate 'MSScriptControl.ScriptControl', @object OUTP

I'm successfully using the 'MSScriptControl.ScriptControl' from within a sql
stored procedure.
[ I use this object to evaluate dynamically generated mathematical
expressions (stored in db tables):
A=5
B=3
C = 3 * (A+ B)
-- so far so good ]
To enhance security and prevent that potential memory leaks could affect the
sql server process I'm looking for a solution to run the object outside the
memory space of sql server.
According the books this should be possible by adding context level 4
parameter to sp_OACreate. Unfortunately for one or another reason this seems
not to work with this object? Can anybody confirm this is normal behavior
and/or if there is a workaround for this? Any other object with an eval
method could also suite (it does not have to be a full blown scripting
language)
-- These three lines work fine
EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT
EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT,5
EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT,1
-- Creating the object in context level 4 does not work however
-- Get following error msg back
-- Class not registered
EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT,4
Thanks for any help,
BartThe COM Component you are trying to register must be an ActiveX exe for it
to be run out-of-process (context =4, or local as it is called in BOL). If
it is an ActiveX dll, you have to run it in process. You can write your own
wrapper exe around the dll to allow it to run out of process, if you are
somewhat comfortable with Visual Basic or C++.
Jacco Schalkwijk
SQL Server MVP
"Bart Michel" <michel.bart@.pandora.be> wrote in message
news:sG0Rd.27207$aE3.5616@.biebel.telenet-ops.be...
> I'm successfully using the 'MSScriptControl.ScriptControl' from within a
> sql
> stored procedure.
> [ I use this object to evaluate dynamically generated mathematical
> expressions (stored in db tables):
> A=5
> B=3
> C = 3 * (A+ B)
> -- so far so good ]
> To enhance security and prevent that potential memory leaks could affect
> the
> sql server process I'm looking for a solution to run the object outside
> the
> memory space of sql server.
> According the books this should be possible by adding context level 4
> parameter to sp_OACreate. Unfortunately for one or another reason this
> seems
> not to work with this object? Can anybody confirm this is normal behavior
> and/or if there is a workaround for this? Any other object with an eval
> method could also suite (it does not have to be a full blown scripting
> language)
>
> -- These three lines work fine
> EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT
> EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT,5
> EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT,1
> -- Creating the object in context level 4 does not work however
> -- Get following error msg back
> -- Class not registered
> EXEC @.hr = sp_OACreate 'MSScriptControl.ScriptControl', @.object OUTPUT,4
> Thanks for any help,
> Bart
>
>
>|||Thanks. The object 'MSScriptControl.ScriptControl' is indeed not an exe file
but ocx (msscript.ocx).
Unfortunatly I've never wrapped an ocx into an exe ... !
Do you have any idea if I should be concerned about memory leaks or other
harm that this MS ocx object could bring to the sql server process? (If
running it already with AllowUI = Off and UseSafeSubset = On)
Would you have any advice to use another control to get the eval
functionality inside T-SQL?
Rgds,
Bart
"Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid> wrote
in message news:exBCBePFFHA.1292@.TK2MSFTNGP10.phx.gbl...
> The COM Component you are trying to register must be an ActiveX exe for it
> to be run out-of-process (context =4, or local as it is called in BOL). If
> it is an ActiveX dll, you have to run it in process. You can write your
> own wrapper exe around the dll to allow it to run out of process, if you
> are somewhat comfortable with Visual Basic or C++.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "Bart Michel" <michel.bart@.pandora.be> wrote in message
> news:sG0Rd.27207$aE3.5616@.biebel.telenet-ops.be...
>|||Inline.
Jacco Schalkwijk
SQL Server MVP
"Bart Michel" <michel.bart@.pandora.be> wrote in message
news:Uw1Rd.27222$aE3.21433@.biebel.telenet-ops.be...
> Thanks. The object 'MSScriptControl.ScriptControl' is indeed not an exe
> file but ocx (msscript.ocx).
> Unfortunatly I've never wrapped an ocx into an exe ... !
> Do you have any idea if I should be concerned about memory leaks or other
> harm that this MS ocx object could bring to the sql server process? (If
> running it already with AllowUI = Off and UseSafeSubset = On)
You are probably better of asking the above questions in a VB newsgroup. You
will have more chance of a quick and correct reply there.

> Would you have any advice to use another control to get the eval
> functionality inside T-SQL?
You might be able to do this completely in T-SQL, but you would have to post
more information. (See www.aspfaq.com/5006 for what to post)

> Rgds,
> Bart
>
> "Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid>
> wrote in message news:exBCBePFFHA.1292@.TK2MSFTNGP10.phx.gbl...
>

No comments:

Post a Comment