10.2 SqlWorkspaceFactory Error

3239
1
Jump to solution
09-25-2013 07:03 AM
FrancescoGiovinazzo
New Contributor III
Hello,

in 10 and 10.1 i have an AddIn wich opens an SqlWorkspaceFactory and then loads some QueryLayers based on custom code, everything is working smoothly.

What is failing, in 10.2, is the code wich opens the Workspace from the WorkspaceFactory, with a generic E_FAIL error

For testing purposes i created a new addin with a single button using 10.2 sdk and tried to open the same workspace withot anything else, the same error is returned, here is the code:

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SqlWorkspaceFactory");  IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);  IPropertySet props = new PropertySetClass(); props.SetProperty("DBCLIENT", "Oracle10g"); props.SetProperty("SERVERINSTANCE", "..."); props.SetProperty("AUTHENTICANTION_MODE", "DBMS"); props.SetProperty("USER", "..."); props.SetProperty("PASSWORD", "...");  IWorkspace pWorkspace = workspaceFactory.Open(props, 0);


The full error is:
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

Note that:
- tnsping on the server instance is working
- the same db from a 10 or 10.1 machine is working
- user and password are the same and working
- sql plus connection on the machine is working
- oracle client version is the same between 10, 10.1 and 10.2

Any clue about this error?

Thanks in advance

Fra
0 Kudos
1 Solution

Accepted Solutions
FrancescoGiovinazzo
New Contributor III
I sorted it out.

It seems that in 10.2 the SqlWorkspaceFactory is nomore supported, there is no online documentation yet and in the local help the chapter "Working with sql workspaces" is nowhere to be found.

Searching for the SqlWorkspaceFactory documentation in the local help, the description is subtle:
The SDEWorkspaceFactory.Open method should be used to make connections to all databases and enterprise geodatabases.

If you just give a quick look at the documentation, you may missing that it suggest to use the SDE and not Sql one, without any explaination or anything else.

Based on this, i updated my code to this one:

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);  IPropertySet props = new PropertySetClass();  props.SetProperty("instance", "sde:oracle10g:elisadev_sigmarer.core.it"); props.SetProperty("user", "..."); props.SetProperty("password", "...");  IWorkspace pWorkspace = workspaceFactory.Open(props, 0);  ISqlWorkspace sqlWorkspace = pWorkspace as ISqlWorkspace;


I discovered the correct instance by adding a query layer from arcmap, now everything works again.

Beware of the evil SqlWorkspaceFactory in 10.2

Hope this helps someone else saving time.

Fra

View solution in original post

1 Reply
FrancescoGiovinazzo
New Contributor III
I sorted it out.

It seems that in 10.2 the SqlWorkspaceFactory is nomore supported, there is no online documentation yet and in the local help the chapter "Working with sql workspaces" is nowhere to be found.

Searching for the SqlWorkspaceFactory documentation in the local help, the description is subtle:
The SDEWorkspaceFactory.Open method should be used to make connections to all databases and enterprise geodatabases.

If you just give a quick look at the documentation, you may missing that it suggest to use the SDE and not Sql one, without any explaination or anything else.

Based on this, i updated my code to this one:

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);  IPropertySet props = new PropertySetClass();  props.SetProperty("instance", "sde:oracle10g:elisadev_sigmarer.core.it"); props.SetProperty("user", "..."); props.SetProperty("password", "...");  IWorkspace pWorkspace = workspaceFactory.Open(props, 0);  ISqlWorkspace sqlWorkspace = pWorkspace as ISqlWorkspace;


I discovered the correct instance by adding a query layer from arcmap, now everything works again.

Beware of the evil SqlWorkspaceFactory in 10.2

Hope this helps someone else saving time.

Fra