How to access .gdb file from windows forms application

5419
1
Jump to solution
01-20-2015 10:48 PM
SrikanthHemadri
New Contributor II

Hi, I am new to arcobjects. I want to create a windows forms application and access a Geodatabase(.gdb) file from it and access the data at table level. I am using C#.

Please Help me.

0 Kudos
1 Solution

Accepted Solutions
nicogis
MVP Frequent Contributor

Create a project in VS (install sdk arcobjects for .net)

Cattura.PNG

//Connect to geodatabase

// For example, path = @"C:\myData\myfGDB.gdb".

public static IWorkspace FileGdbWorkspaceFromPath(String path)

{

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");

IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

return workspaceFactory.OpenFromFile(path, 0);

}

//open table

IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;

ITable table= featureWorkspace.OpenTable("YourTable");

View solution in original post

1 Reply
nicogis
MVP Frequent Contributor

Create a project in VS (install sdk arcobjects for .net)

Cattura.PNG

//Connect to geodatabase

// For example, path = @"C:\myData\myfGDB.gdb".

public static IWorkspace FileGdbWorkspaceFromPath(String path)

{

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");

IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

return workspaceFactory.OpenFromFile(path, 0);

}

//open table

IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;

ITable table= featureWorkspace.OpenTable("YourTable");

View solution in original post