ArcObject with database connection

970
2
03-14-2021 09:31 PM
rajujee
New Contributor III

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.

R

0 Kudos
2 Replies
KirkKuykendall1
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
rajujee
New Contributor III

Thanks KirkKuykendall1 for sharing code. It is helpful. 

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

0 Kudos