I'm trying to open a workspace from the IWorkspaceFactory interface. Here's what I'm trying at the moment:
ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pLayer;
ESRI.ArcGIS.Geodatabase.IFeatureClass oldFeatureClass = featureLayer.FeatureClass;
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("INSTANCE", newData.instance); //sde:sqlserver:(servername)
propertySet.SetProperty("DATABASE", newData.database); //(databasename)
propertySet.SetProperty("AUTHENTICATION_MODE", newData.autMode); //OSA
propertySet.SetProperty("VERSION", newData.version); //sde.DEFAULT
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);
For my properties I have also tried the following:
propertySet.SetProperty("SERVER", serverName);
propertySet.SetProperty("INSTANCE", "sde:sqlserver:(database)");
propertySet.SetProperty("DATABASE", "SDE");
propertySet.SetProperty("AUTHENTICATION_MODE", newData.autMode); //OSA
propertySet.SetProperty("VERSION", newData.version); //sde.DEFAULT
I know that the property settings are the issue as when I try using
propertySet.SetProperty("SERVERINSTANCE", serverName);
It shows the new connection dialog.
To give you an idea of my values, I consider Instance in this window to be the server name. I consider database to be the database name. This should give you an idea of what I'm setting my values as.
Is there a property value that I'm missing or a value that is incorrect?
Edit: Based on comment I have added a revised property set that brings up the database connection screen still, but everything is filled out. However, users can still edit the authentication type, which for some people may be confusing. I would like to just skip that screen and have it connect without any user input.
propertySet.SetProperty("SERVERINSTANCE", "(instance)\\(database)");
propertySet.SetProperty("DBCLIENT", "SQLServer");
propertySet.SetProperty("VERSION", newData.version); //sde.DEFAULT
propertySet.SetProperty("AUTHENTICATION_MODE", newData.autMode); //OSA
I have tried entering my Operating system authentication credentials under
propertySet.SetProperty("user", "username");
propertySet.SetProperty("password", "password");
However, this still shows the screen and the credentials aren't filled in on the form. (The screen I'm referring to is the database connection form screenshot above.)