ArcObject with database connection

03-14-2021 09:31 PM
New Contributor II

Good day,

I am new to ArcObjects. Any help or guidance is deeply appreciated.

I have installed ArcObjects with Visual Studio 2015. I am using ArcMap 10.6. I need guidance connecting ArcObjects Adddatabase (sql server 2012) with VS 2015. Can I connect  with web service only?

I am connecting with C# as a desktop application and getting errors. Is there a sample code I could re-use?

Thanks for reading.


0 Kudos
2 Replies
Occasional Contributor III

There are a lot of samples in this github repo, like this one.

public static IWorkspace GetWorkspace()
    Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
    IWorkspace workspace = workspaceFactory.OpenFromFile(@"C:\Users\YourUserName\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\express2014@samigdb.sde", 0);
    return workspace;


0 Kudos
New Contributor II

Thanks KirkKuykendall1 for sharing code. It is helpful. 

Could you also share sample code to connect sql server database.

0 Kudos