Hello Team,
I need a help to connect geodatabase using ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2.OpenFromString method
I coded like below (I have pasted only necessary part of code where i have issue)
I am getting below print statements from my Log file, after that not getting and DB connection also not established.
ErrorHandling.WriteStatusMessage("CommandManager_LoadSde", "Open SDE workspace");
ErrorHandling.WriteStatusMessage("Connection String", gConnectionString);
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 pFact = null;
pFact = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2)new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory();
ESRI.ArcGIS.Geodatabase.IWorkspace pWorkspace = null;
String gConnectionString = "DBCLIENT=postgresql"
+ "SERVER=" + "<serverIP address>"
+ ";DATABASE=" + "<DBName>"
+ ";INSTANCE=" + "<port>"
+ ";USER=" + <user>
+ ";PASSWORD=" + <pwd>
+ ";VERSION=sde.DEFAULT";
ErrorHandling.WriteStatusMessage("CommandManager_LoadSde", "Open SDE workspace");
ErrorHandling.WriteStatusMessage("Connection String", gConnectionString);
// PJD DEBUG:
//System.Windows.Forms.MessageBox.Show("gConnectionString is: " + gConnectionString);
pWorkspace = MemoryHelper.ReleaseAndCleanObject<ESRI.ArcGIS.Geodatabase.IWorkspace>(pWorkspace, pFact.OpenFromString(gConnectionString, 0));
System.Diagnostics.Debug.WriteLine("CommandManager_LoadSde", "Setting Workspace path=" + pWorkspace.PathName);
pPropertySet.SetProperty("WORKSPACE", pWorkspace);
//Set property and execute load sde command
clsLoadSdeSource pLoadSdeSource = MapTools.MapToolsFactory.Create<clsLoadSdeSource>(null, false);
pLoadSdeSource.LayerConfig = pPropertySet;
pLoadSdeSource.SdeWorkspace = pWorkspace;
ErrorHandling.WriteStatusMessage("CommandManager_LoadSde", "Call loadSdeSource.execute");
Please help me to fix this issue.
Thanks!