I am writting an ArcMap-AddIn with vb.net. I got an error when trying to compact
my IWorkspace(mdb), the error is:
我正在用vb.net写一个ArcMap-AddIn。我在试图压缩IWorkspace(mdb)时出错,错误是:
COMException
COMException
You tried to open a database, which was already opened by the user 'ADMIN' on Computer 'XXXXXX'. Try it again when the database is available.
您试图打开一个数据库,该数据库已经由用户“ADMIN”在计算机“XXXXXX”上打开。当数据库可用时再试一次。
On ESRI.ArcGIS.Geodatabase.IDatabaseCompact.Compact() on MyProject.MyClass.CompactGDB(IWorkspace pWS)
在ESRI.ArcGIS.Geodatabase.IDatabaseCompact.Compact MyProject.MyClass()。CompactGDB(IWorkspace pWS)
How can i compact the used workspace? There are 8 other functions which also used my workspace.
如何压缩所使用的工作区?还有8个函数也使用了我的工作空间。
Any suggestions?
有什么建议吗?
The Code:
代码:
' CompactGDB
Public Sub CompactGDB(ByVal pWS As IWorkspace)
Dim pDatabaseCompact As IDatabaseCompact
If (TypeOf pWS Is IDatabaseCompact) Then
pDatabaseCompact = CType(pWS, IDatabaseCompact)
If (pDatabaseCompact.CanCompact) Then
Try
pDatabaseCompact.Compact()
Catch ex As Exception
MessageBox.Show(ex.type & ex.Message & ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End If
End Sub
1 个解决方案
#1
0
Found the solution:
找到了解决方案:
Before calling the Compact() method make sure there are not any existing locks on the database.
在调用Compact()方法之前,请确保数据库上没有任何现有锁。
If it is a file geodatabase then open the gdb directory in Windows Explorer and look for LOCK type files, they end in .lock.
如果它是一个文件geodatabase,然后在Windows资源管理器中打开gdb目录并查找锁类型文件,它们将以. LOCK结束。
For personal geodatabase there will be a .ldb file in the directory with the same name as the .mdb.
对于个人地理数据库,在目录中将有一个与.mdb相同名称的.ldb文件。
- If you have a layer or table from the geodatabase loaded in the map then you will not be able to remove all locks.
- 如果您在地图上的地理数据库中有一个层或表,那么您将无法删除所有的锁。
- If another user is accessing the geodatabase then you will not be able to remove all locks.
- 如果另一个用户正在访问geodatabase,那么您将无法删除所有的锁。
- If you are using arcobjects to temporarily access the geodatabase then you need to use good practices and close any geodatabase resources when the calling process ends. This includes releasing all COM objects when you are finished with them.
- 如果您正在使用arcobjects临时访问geodatabase,那么您需要在调用过程结束时使用良好的实践并关闭任何地理数据库资源。这包括在结束时释放所有COM对象。
Use the ComReleaser Class in ESRI.ArcGIS.ADF.Connection.Local namespace
在ESRI.ArcGIS.ADF.Connection中使用ComReleaser类。本地名称空间
#1
0
Found the solution:
找到了解决方案:
Before calling the Compact() method make sure there are not any existing locks on the database.
在调用Compact()方法之前,请确保数据库上没有任何现有锁。
If it is a file geodatabase then open the gdb directory in Windows Explorer and look for LOCK type files, they end in .lock.
如果它是一个文件geodatabase,然后在Windows资源管理器中打开gdb目录并查找锁类型文件,它们将以. LOCK结束。
For personal geodatabase there will be a .ldb file in the directory with the same name as the .mdb.
对于个人地理数据库,在目录中将有一个与.mdb相同名称的.ldb文件。
- If you have a layer or table from the geodatabase loaded in the map then you will not be able to remove all locks.
- 如果您在地图上的地理数据库中有一个层或表,那么您将无法删除所有的锁。
- If another user is accessing the geodatabase then you will not be able to remove all locks.
- 如果另一个用户正在访问geodatabase,那么您将无法删除所有的锁。
- If you are using arcobjects to temporarily access the geodatabase then you need to use good practices and close any geodatabase resources when the calling process ends. This includes releasing all COM objects when you are finished with them.
- 如果您正在使用arcobjects临时访问geodatabase,那么您需要在调用过程结束时使用良好的实践并关闭任何地理数据库资源。这包括在结束时释放所有COM对象。
Use the ComReleaser Class in ESRI.ArcGIS.ADF.Connection.Local namespace
在ESRI.ArcGIS.ADF.Connection中使用ComReleaser类。本地名称空间