Why does opening SDE Workspace Factory ask for credentials again?

1347
4
03-10-2019 12:56 AM
Muhammad_TayyabMir
New Contributor II

I'm trying to open SDE Workspace Factory using IWorkspaceFactory.Open

I give the complete Property set in the code to open.

ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
propertySet.SetProperty("SERVER", "myServer");
propertySet.SetProperty("INSTANCE", "myinstance");
propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS");
propertySet.SetProperty("DATABASE", "myDatabase");
propertySet.SetProperty("USER", "sde");
propertySet.SetProperty("PASSWORD", "sdePassword");
propertySet.SetProperty("VERSION", "sde.DEFAUALT"); 

IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory(); 
IWorkspace workspace = workspaceFactory.Open(propertySet,0);

But When the workspaceFactory.Open is called, a dialogue box is opened to ask for credentials again.

Why does this happen?

Also, Can someone tell me what does the second parameter of IWorkspaceFactory.Open "hWnd" represent? I couldnt find a proper explanation in the documentation.

0 Kudos
4 Replies
JoeHershman
MVP Regular Contributor

Assuming this is a copy of your actual code just with removed password and server. You spelled default wrong, which would cause it to not open automatically.

The hWnd represents the window handle of a parent window.  This only comes into play if you were writing a custom standalone application.  Then you could use the handle of the form that was the parent of the dialog.  But if you don't want it to open than 0 is the proper value.  Also even in a standalone 0 works just fine.

Thanks,
-Joe
0 Kudos
Muhammad_TayyabMir
New Contributor II

Hi there. Thank you for your response.
Yes this is a copy of the original code. These are variables,coming as parameters, in the original code. So I changed them here for the clarity of code. The spellings are correct in the original code.

One tricky property for me is the "instance". I'm not really sure which is the correct value to use.
If I right click my ArcSDE database in ArcCatalog, and click on "Connection Properties", the instance value is same as my Server name (raecgissql)

 

But when I open the connection properties from the SQL Server Management Studio, The Instance is shown to be empty.

When I use, empty string in my code. No exception is thrown, but it asks for the credentials again.
When I use "raecgissql" (similar to ArcCatalog) then an exception is thrown , something like "SDE not found in the listings".

0 Kudos
JeffMatson
Occasional Contributor III

Are you attempting to pass in Direct-Connect parameters in your property set?  If so you likely need to add several parameters, and also make sure your Instance parameter is correct.  (We have an Oracle database and the Instance parameter to be passed in via PropertySet is different than what ArcCatalog reports - not sure if that is the same for your SQL Server database or not...)

0 Kudos
MichaelBarsky
New Contributor II

I had the same problem, until i try to set the "instance" property to "sde:sqlserver:MY_SQLSERVER_NAME". And is all right.