2

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!

2
  • Is it a normal ITable? What is the exact problem you are facing now?
    – Emi
    Commented Jan 30, 2013 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
    Commented Jan 30, 2013 at 8:56

1 Answer 1

3

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.

1
  • This link is for ArcObjects. What library I should install before using the code? Because they are in red color Commented Jul 25, 2021 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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