Re: sp_OACreate simple question

From: Greg Linwood (g_linwoodQhotmail.com)
Date: 05/21/04


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



Relevant Pages

  • Re: Clickonce and license question question
    ... updates the SQL server at our ISP that the license key is now in use. ... They are unable to register the application and they get an SQL error. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: MComm control
    ... When you go to register the .ocx on a machine (from within Access, ... you go Tools> ActiveX Controls, click on Register, locate the .ocx ... > Access is installed on the server AND each PC. ...
    (microsoft.public.access.modulesdaovba)
  • Re: computer browser service wont start
    ... I've noticed that dnsApi is sometimes one of the things that starts early before everything it needs is actually working, e.g. the TCP/IP and network stack. ... In the situations I've seen the Event Log entry from dnsApi that you report, the computer did successfully register itself later. ... This assumes that the targetted DNS server can accept Dynamic registrations and the computer doing the dynamic registration is permitted to do so. ...
    (microsoft.public.windows.server.general)
  • Re: Local instances being used for all linked (remote) instances
    ... Try registring the server using the IP and port number instead of the DNS ... Wayne Snyder, MCDBA, SQL Server MVP ... > In enterprise manager on SRV1 you can register remote default instances ... local SRV1 system or if the password is different, it can't register it. ...
    (microsoft.public.sqlserver.server)
  • Re: Clickonce and license question question
    ... would prefer to change the way we license / register the application. ... updates the SQL server at our ISP that the license key is now in use. ... What about just meaking the company open their firewall for the server? ...
    (microsoft.public.dotnet.framework.windowsforms)