I am relatively new to ArcObjects or I should say I haven't done this in a while. I am trying to edit an sde table within a Map document but can't seem to find any examples of how to do this the way i want. Basically, i have reference to the table in the map document via the IActiveView ITableCollection interface. I need to edit/create rows to the table. I need help in starting an edit session without having to specify IpropertySet properties. I guess what I am driving at is to be able to somehow know the SdeWorkspaceFactory from the table in the map document. I have tried creating the SdeWorkspaceFactory but keep getting "Sde not running on Server" error.
I would like something like these rather than what i have below.
ITableCollection tableCollection = activeView as ITableCollection;
ITable mappingTable = tableCollection.get_Table(0);
IWorkspace wkspc = mappingTable.workspace // IS IT SOMEHOW POSSIBLE TO GET THE WORKSPACE FROM THE TABLE OR LAYER/FEATURECLASS?
---------------------------------------------------------
THIS IS WHAT I CURRENTLY HAVE
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
// Create a property set and populate it with connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("SERVER", System.Configuration.ConfigurationSettings.AppSettings["SERVER"]);
propertySet.SetProperty("INSTANCE", System.Configuration.ConfigurationSettings.AppSettings["INSTANCE"]);
propertySet.SetProperty("DATABASE", System.Configuration.ConfigurationSettings.AppSettings["DATABASE"]);
propertySet.SetProperty("USER", System.Configuration.ConfigurationSettings.AppSettings["USER"]);
propertySet.SetProperty("PASSWORD", System.Configuration.ConfigurationSettings.AppSettings["PASSWORD"]);
propertySet.SetProperty("VERSION", System.Configuration.ConfigurationSettings.AppSettings["VERSION"]);
string msg = "";
IWorkspace workspace = null;
IWorkspaceEdit workspaceEdit = null;
try
{
// Open the geodatabase using the property set.
workspace = workspaceFactory.Open(propertySet, 0); // BTW I KEEP GETTING TETH "SDE NOT RUNNING ON SERVER ERROR" here.
IMultiuserWorkspaceEdit and IWorkspaceEdit2 interfaces.
IMultiuserWorkspaceEdit muWorkspaceEdit = workspace as IMultiuserWorkspaceEdit;
workspaceEdit = workspace as IWorkspaceEdit;
// Start a versioned edit session and an edit operation.
muWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
workspaceEdit.StartEditOperation();
}
catch (COMException comExc1)
{
msg = comExc1.Message;
}