Solved

SQL 2000 not releasing COM+ component

Posted on 2002-04-25
4
318 Views
Last Modified: 2013-11-25
I'm running triggers that instantiate a .NET COM+ object via sp_OACreate, call a method via sp_OAMethod, then release it via sp_OADestroy. Everything works great.

The problem is with deployment. If I want to deploy a new version of the .NET COM+ object - even if the interface is unchanged, I have to restart SQL Server to release the handle on it. sp_OADestory should do that for me, but for some reason, SQL Server still holds onto it. This happens even if I shutdown the object in Component Services.

Any ideas of why this is happening and how to get around it? Thanks.
0
Comment
Question by:dplambert
  • 2
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6968682
Check out this:

DBCC dllname (FREE)
Unloads the specified extended stored procedure dynamic-link library (DLL) from memory.

Examples
This example assumes an extended procedure xp_sample is implemented as Xp_sample.dll and has been executed. It uses the DBCC dllname (FREE) statement to unload the Xp_sample.dll file associated with the xp_sample extended procedure.

DBCC xp_sample (FREE)

CHeers
0
 
LVL 3

Author Comment

by:dplambert
ID: 6968991
Well, it's not an extended stored procedure. Here's the code:

CREATE TRIGGER dbo.TrailerAfterInsertUpdate
     ON Trailer AFTER INSERT, UPDATE
AS

SET NOCOUNT ON

/* can't affect more than 1 record at a time */
IF ( SELECT COUNT(*) FROM inserted ) > 1 BEGIN
     RAISERROR('multiple INSERTs/UPDATEs not supported in TrailerAfterInsertUpdate trigger', 16, 1) WITH LOG
     RETURN
END

/* get primary key data */
DECLARE
     @TerminalId    CHAR(4),
     @TrailerNumber CHAR(12)

SELECT
     @TerminalId    = TerminalId,
     @TrailerNumber = TrailerNumber
FROM
     inserted

/* call middle tier component */
DECLARE
     @ihandle INT,
     @ireturn INT,
     @breturn BIT,
     @message VARCHAR(400)

EXEC @ireturn = sp_OACreate 'CTII.XDOCK.X2PUtil.TriggerHandler', @ihandle OUT
IF @ireturn = 0 BEGIN
     EXEC @ireturn = sp_OAMethod
          @ihandle,
          'CloseTrailer',
          @breturn OUT,
          @TerminalId,
          @TrailerNumber
     IF @ireturn <> 0 SET @message = 'unable to OAMethod'

     EXEC @ireturn = sp_OADestroy @ihandle
     IF @ireturn <> 0 AND @message IS NULL SET @message = 'unable to OADestory'
END
ELSE
     SET @message = 'unable to OACreate'

IF @message IS NOT NULL BEGIN
     SET @message = @message + ' in TrailerAfterInsertUpdate trigger, pk{'
                    + 'TerminalId=' + @TerminalId + ','
                    + 'TrailerNumber=' + @TrailerNumber + '}'
     RAISERROR(@message, 16, 1) WITH LOG
END

IF @breturn = 1
     UPDATE
          Trailer
     SET
          ToHostDateTime = CURRENT_TIMESTAMP
     WHERE
          TerminalId    = @TerminalId AND
          TrailerNumber = @TrailerNumber
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6970677
Your code seems fine.

Now, 'CTII.XDOCK.X2PUtil.TriggerHandler' is in a dll, i assume CTII.dll.
You might use:
DBCC CTII (free)

CHeers
0
 
LVL 3

Author Comment

by:dplambert
ID: 6971272
The command that worked was: DBCC X2PUtil (FREE), because that was the actual DLL name.

Thanks a lot for the help!!!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question