Solved

SQL 2000 not releasing COM+ component

Posted on 2002-04-25
4
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

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 143

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
query analyser in sql server 2016 express edition 2 25
sql server cross db update 2 20
SQL Syntax 6 41
getting error while running below query  in sql 2 14
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

756 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