I am currently in the process of converting our VBA apps to .net (C#) using Visual Studio 2010 and ArcGIS 10.1.
On my current project, I want to add a layer to the map from SDE.
I have the following code...
public void AddSDELayer(string server, string featureClassName)
{
//create feature layer
IFeatureLayer featureLayer = new FeatureLayer();
//Create a workspace factory
IWorkspaceFactory sdeWSFactory = new SdeWorkspaceFactory();
//Create the property connections
IPropertySet connectionProperties = new PropertySetClass();
connectionProperties.SetProperty("SERVER", server);
connectionProperties.SetProperty("INSTANCE", "5159");
connectionProperties.SetProperty("USER", "anyone");
connectionProperties.SetProperty("PASSWORD", "anyone");
connectionProperties.SetProperty("VERSION", "SDE.DEFAULT");
// create a workspace
IWorkspace WS = sdeWSFactory.Open(connectionProperties, 0);
//create featureworkspace
IFeatureWorkspace featWS = WS as IFeatureWorkspace;
//create feature class
IFeatureClass featureClass;
//Open the feature class
featureClass = featWS.OpenFeatureClass(featureClassName);
//set the feature layer to the featureclass
featureLayer.FeatureClass = featureClass;
featureLayer.Name = featureClass.AliasName;
//Add the layer to the map
map.AddLayer(featureLayer);
MessageBox.Show(featureLayer.Name + " Added to map");
}
However when it gets to the following line
//Open the feature class
featureClass = featWS.OpenFeatureClass(featureClassName);
I get the following error in VS.
DBMS table not found [ORA-00942: table or view does not exist ] [SY_DES_HM.Carriageway][STATE_ID = 596]
I've tried it with various layers that do exist, but the VS still doesn't like it, where am i going wrong?
Thanks