Connect to geodatabase using .SDE file

Discussion created by Jamari_L_Powers on Apr 25, 2014
Latest reply on May 3, 2014 by Ahmed.ElSisiesrinea-esridist
Working in C#

I have been working with arcObjects and researching connecting to a geodatabase. I already have a working .SDE file created. Again, my lack of understanding and the convolution from the ArcGIS resource center is causing me confusion. I am not sure where to start exactly. I have bits and pieces as far as understanding.

I believe I must start with an IFeatureWorkspace. From this I am supposed to use sdeWorkspaceFactoryClass, correct? I was going to use a line of code as follows:

IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
m_ReadOnlyWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(nameOfFile, 0);

where "m_ReadOnlyWorkspace" is my created workspace and "nameOfFile" is my sde file. Should my "nameOfFile" variable be the entire path to the .SDE file or just the name of the file?

Once I am able to make this line work, I should be [connected] to the database and able to run a query from a table correct? Am I missing any intermediate steps in the process?

Any help or insight on these issues / questions would be greatly appreciated. Thanks in advance.