Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've a personal geodatabase which has some shape files included. To get a "complex" relation I've created a single table which will be have 1:1 or 1:N references which the different shape files (atm. 3).

Now I want to know how I can:

  1. access the table in the personal geodatabase,
  2. add new entries to this table,
  3. remove/modify existing entries

using C#. Does anybody done this before and can help me to solve this question?

Thanks a lot!

share|improve this question
    
Is it a normal ITable? What is the exact problem you are facing now? –  Emi Jan 30 '13 at 8:33
    
I've created the table unsing ArcCatalog and I dont know how I can handle and access this tavble in C#. –  FredFloete Jan 30 '13 at 8:56

1 Answer 1

up vote 2 down vote accepted

If you are working with personal geodatabase, this code should work for you. For other kind of workspace, to open the workspace, you need different type of workspace factory.

void DoTableProcessing(string workspacePath)
{
    IWorkspace workspace = OpenWorkspace(workspacePath);
    List<ITable> tables = GetTables(workspace);
    //Do process
}

List<ITable> GetTables(IWorkspace workspace)
{
    var enumDataset = workspace.Datasets[esriDatasetType.esriDTTable];
    var datasets = new List<ITable>();
    IDataset dataset;
    while ((dataset = enumDataset.Next()) != null)
        datasets.Add(dataset as ITable);
    return datasets;
}

IWorkspace OpenWorkspace(string workspacePath)
{
    IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactoryClass();
    return workspaceFactory.OpenFromFile(path, 0);
}

To do work with ITable you may see ITable interface. You can do search, select, modify, add rows through this interface.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.