SQL Server Connection via SdeWorkspaceFactoryClass
We were having problems trying to connect to ArcSDE 10.1 when using SdeWorkspaceFactoryClass. We had no problems attaching to ArcSDE 10.0 but kept getting a "SDE not running on server" error when trying to connect to 10.1. After some searching we were able to determine that we had to add two properties to the IPropertySet to gain access to 10.1 that we did not need against prior versions. They are DB_CONNECTION_PROPERTIES and DBCLIENT. (These properties are used when performing a direct connection to SDE. Previously we were not using direct connect but were establishing a connection to an SDE instance. ArcSDE 10.1 does NOT use instances so we have had to change to using the direct connect method.) For example, we would use the following code to fill the property set: public static IPropertySet GetPropertySetClass() { IPropertySet props; props = new PropertySetClass(); props.SetProperty("DB_CONNECTION_PROPERTIES", "sde_server_name"); props.SetProperty("DBCLIENT", "SQLServer"); props.SetProperty("DATABASE", "db_name"); props.SetProperty("USER", "staff"); props.SetProperty("PASSWORD", "XXXXXX"); props.SetProperty("VERSION", "sde.DEFAULT"); return props; } Then, to open the connection, use the following: public static IFeatureClass OpenFeatureClassFromSde(string LayerName) { IWorkspace ws; IWorkspaceFactory wsf; IFeatureWorkspace fws; IPropertySet props; props = Helper.GetPropertySetClass(); wsf = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass(); ws = wsf.Open(props, 0); fws = ws as IFeatureWorkspace; return fws.OpenFeatureClass(LayerName); }










