Skip to main content
added 168 characters in body
Source Link
Emi
  • 2.4k
  • 2
  • 23
  • 40

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.

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);
}

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.

Source Link
Emi
  • 2.4k
  • 2
  • 23
  • 40

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);
}