Close SDE connection

2888
4
04-20-2010 06:33 AM
deleted-user-VeZur_n9o0OZ
New Contributor III
Hello,

I have a function which creates an SDE connection. My connection is immediately visible on the server using the command: sdemon -o -info -I users. However, i am unable to close the connection until ArcMap is closed. I'd like to do so, as i'm using iSchemaLockInfo to detect locks in a seperate function which may run simultaneously

I've dug through the old forums and found a few suggestions - none of which have worked. I have tried so far...
1. Setting my workspace and workspacefactory to nothing
2. Marshal.ReleaseComObject() for the factory and workspace
3. Using iGxRemoteConneciton.disconnect()

So i'm out of ideas. Can anybody close my connection?

Also - my connections never close if i run my code in debug mode. Is that normal? At the moment i'm killing them each time

Finally - my second function edits a coded value domain (empties it, re-populates it). As domains are stored at the workspace level, i figured i should check for connections to the workspace before doing anything. Is this necessary?


Thanks to all,
James



I am opening a SDE feature workspace as follows...

'Connect to workspace
Dim workspacefactory As IWorkspaceFactory = New SdeWorkspaceFactory
Dim featureworkspace As IFeatureWorkspace = CType(workspacefactory.Open(propertyset, 0), IFeatureWorkspace)
0 Kudos
4 Replies
KirkKuykendall
Occasional Contributor III
I'm also curious about this.

I tried IDataLayer2.Disconnect in 9.2 or so.  It didn't work, but maybe something has changed so might be worth trying.
0 Kudos
deleted-user-VeZur_n9o0OZ
New Contributor III
Hi Kirk,

Yes I saw your previous postings. I'm still at 9.2 unfortunately. My function is run through ArcMap for the benefit of my users, but there are no layers in the TOC. I only use featureclasses which i'm grabbing from my SDE geodatabase.

Can anyone confirm whether they've successfully closed a connection to an SDE workspace previously? if so, how?

Thanks
0 Kudos
KirkKuykendall
Occasional Contributor III
what happens if you create a featurelayer with the featureclass and call IDatalayer2.Disconnect on the featureclass when you a through with it (and after calling releasecomobject on the workspace and workspacefactory)?
0 Kudos
LukeBadgerow
New Contributor
this is a bit of a bump.

I noticed this morning as I was working through an error that was causing my application to crash that I was left with a number of orphan SDE Connections, which led me to investigating how we should close these connections (COM Releaser is a little clunky for me).  As I've been reading, it doesn't look like anyone pays any attention to this, and the API Reference for IWorkspace or IWorkspaceFactory have no methods to Close. 

Has anyone found a good work around?
0 Kudos