Solved

SQL 2000 not releasing COM+ component

Posted on 2002-04-25
4
298 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]
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
The command that worked was: DBCC X2PUtil (FREE), because that was the actual DLL name.

Thanks a lot for the help!!!
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now