?
Solved

SQL 2000 not releasing COM+ component

Posted on 2002-04-25
4
Medium Priority
?
358 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 400 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

762 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