AnsweredAssumed Answered

ArcSDE WorkspaceFactory Connection Error

Question asked by kdoman on Sep 25, 2012
Latest reply on Sep 25, 2012 by kdoman
Part of my addin is trying to connect to what could be a SDE connection. I'm using WorkspaceFactory.OpenfromFile to connect to the geodatabase, because the connection could be to a file geodatabase, personal geodatabase, or an sde connection.

Here's where my error is coming in. When I set the location of my connection file to the absolute location (C:\Users\ ... \ArcCatalog\myGIS.sde), it connects fine. But when I set it to "Database Connections\myGIS.sde", which is the location I get when I use the ArcCatalog dialog to browse to the geodatabase, the connection throws an error.

Is there a way to get the file location for the database connection file programmatically? I want to use OpenFromFile because I don't want to handle user names and passwords, and because I can open other geodatabases with the same code.

Here's an edited snippet of my code:

 ' code works when connection = "C:\Users\ ... \ArcCatalog\myGIS.sde"  Dim connection as String = "Database Connections\myGIS.sde"  Dim myWorkspace as IWorkspace Dim factoryType as Type = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory") Dim myWorkspaceFactory = Ctype(Activator.CreateInstance(factoryType), IWorkspaceFactory)  myWorkspace = myWorkspaceFactory.OpenFromFile(connection, 0) ' here is where I get the error.