StartEditing that return true/false

1577
3
07-08-2011 06:54 AM
ValeriaAndronaco
New Contributor
Hi forum,
I ahave an important question.
I have an application whit an esri mapcontrol that allow the user to add point to the map.
I need to know if the editing can start.
For example, if another user is editing in the map, than the first user will see an error.
How can obtain an information true/false from the code:

.....
pWorkspaceEdit.StartEditing(true);
pWorkspaceEdit.StartEditOperation();
....

Can you help me please?

Thanks in advance.
0 Kudos
3 Replies
AlexanderGray
Occasional Contributor III
I too have this problem.  There is the isbeingedited property on the iworkspaceedit, however, this only returns true if the process in which it is called is the one edited.  In my case I had a file geodatabase, where the same user could be editing it from two different processes (.exe)  The only way I found was to check for the presence of edit locks in the file geodatabase folder (*.ed.lock.)  Does anyone have a better way?
0 Kudos
NeilClemmons
Regular Contributor III
If you wrap the call to StartEditing in a Try/Catch block I believe it will throw an exception if the workspace is locked by another user.
0 Kudos
ValeriaAndronaco
New Contributor
Hi Neil,

I followed your suggestion, I wrap StartEditing in a Try/Catch block:

  try
      {
         pWorkspaceEdit.StartEditing(true);
         pWorkspaceEdit.StartEditOperation();
         .........
         .........
       }                   
  catch (Exception ex)
       {
         MessageBox.Show("The workspace is locked by another user");
                    pWorkspaceEdit.UndoEditOperation();
         }

Would be useful to capture UserName and MachineName of the user has just strated the editing.
The exception message has this information, infact the original message is: Can not lock. The table "GDB_DatabaseLocks" is currently used by the user "Admin" on machine "PC5".
How can I get this fields from the table, if the table is locks?
0 Kudos