Re: sp_OACreate simple question
From: Greg Linwood (g_linwoodQhotmail.com)
Date: 05/21/04
- Next message: pileggi: "select fields width NULL"
- Previous message: Peter: "Mail"
- In reply to: Josh White: "Re: sp_OACreate simple question"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 21 May 2004 20:23:34 +1000
Hi Josh
COM servers are registered using the regsvr32.exe utility, but I doubt that
your .ocx is usable as a COM server. Usually, COM servers are packaged as
.dll or .exe but only occasionally as .ocx - that extension is more commonly
used for graphical components, especially if it was developed in VB.
There's usually no harm in attempting to register an .ocx with regsvr32 even
if it doesn't support a COM IDispatch interface. If you do this & the ProgID
doesn't show up under HKEY_CLASSES_ROOT, then you won't be able to call it
via sp_OACreate.
To use regsvr32, you open a command prompt, then type "regsvr32
c:\JWLink.ocx" (assuming the file is in the c:\ directory.
HTH
Regards,
Greg Linwood
SQL Server MVP
"Josh White" <whitegoose@inorbit.com> wrote in message
news:aafea0a8.0405201952.428f9dee@posting.google.com...
> Thanks for the clarification...
>
> At this stage I am only trying to prove a case with a prototype. Again
> I'll point out I've never done anything like this (COM) before.
>
> When I use what I think is the library qualified, period separated
> class reference as the first parameter, I am told that it is an
> invalid class string so I assume I am not naming it correctly.
>
> When I use what I know is the correct CLSID
>
> eg
> EXEC @hr = sp_OACreate '{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}',
> @object OUT
>
> I am told that the class is not registered. I assume this means I have
> correctly identified the class I want to use but I have not registered
> the class with SQL Server.
>
> How do I register the class?
>
>
> Thanks again,
> Josh.
>
>
> "Greg Linwood" <g_linwoodQhotmail.com> wrote in message
news:<uSbThyhPEHA.2704@TK2MSFTNGP10.phx.gbl>...
> > <WHAT GOES IN HERE?> is the COM PROGID, which is the library qualified,
> > period separated class reference, ie: "MyLibraryName.MyClass".
> >
> > Because TSQL's sp_OACreate can only invoke via IDispatch, the COM server
> > MUST support IDispatch. You can confirm this by looking at the library's
IDL
> > ([I]nterface [D]efinition [L]anguage) via the Visual Studio OLE Viewer
or
> > other type library viewer. It must either explicitly name an IDispatch
> > interface or bne marked as "dual". You will always find registry entries
> > under HKEY_CLASSES_ROOT for COM servers with IDispatch interfaces.
> >
> > Also, the .ocx extension often (not always) denotes component types
which
> > either do not support IDispatch (win services) or that are not
appropriate
> > for invocation from server applications such as SQL Server because they
are
> > GUI components (VB6 gui controls were implemented as .ocx's by default).
If
> > such libraries are invoked under SQL Server, any dialogs have no-where
to go
> > because the core SQL Server process where they're invoked from has no
GUI.
> > This results in hung processes & is a very bad idea that can cause a
range
> > of harmful effects to a SQL Server, from bringing it down to forcing
reboot
> > to clear hung processes etc.
> >
> > Bottom line is that you should really be sure about invoking .ocx's from
> > TSQL before doing it (especially from triggers). Check with the vendor
that
> > the .ocx is ok to be invoked before rolling it into your code, & even
then I
> > probably wouldn't trust it & would code defensively by using a layer of
> > indirection - a COM layer that I've written that in turn invokes the
.ocx
> > externally from the SQL process just so that I'm in control. This can be
> > performed in a range of cliient langs, including the newer .Net langs.
> >
> > HTH
> >
> > Regards,
> > Greg Linwood
> > SQL Server MVP
- Next message: pileggi: "select fields width NULL"
- Previous message: Peter: "Mail"
- In reply to: Josh White: "Re: sp_OACreate simple question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|