Library References  

DataSourcesOleDB

Library dependencies: System, SystemUI, Geometry, Display, Server, Output, GeoDatabase, GISClient, DataSourcesFile, DataSourcesGDB


The DataSourcesOleDB library contains the implementation of the GeoDatabase API for the Microsoft OLE DB data sources and text file data sources. These data sources include any OLE DB supported data provider and text file workspaces.

The DataSourcesOleDB library is not extended by developers. It is only available on the Microsoft Windows operating system.


The main objects that implement this functionality are OleDBWorkspaceFactory and TextFileWorkspaceFactory

OleDBWorkspaceFactory and TextFileWorkspaceFactory

A workspace factory object is a dispenser of workspaces and allows a client to connect to a workspace specified by a set of connection properties. A workspace represents a database or a data source that contains one or more datasets. Examples of datasets include tables and feature classes. DataSourcesOleDB has workspace factories for connecting to OLE DB and text file data sources.

Workspace factories are cocreatable, singleton objects. (A singleton object can only be instantiated once in a process.) Each workspace factory maintains a pool of currently connected, active workspaces that are being referenced by the application. Connection properties are specified using a PropertySet object and can be saved to a connection file.

This example demonstrates how to open a table from an OLE DB data source.

//Create and populate a new property set
PropertySet propset = new PropertySet();
propset.setProperty("CONNECTSTRING", "Provider=MSORCL32.1;Data source=mydatabase;User ID=gdb;Password=gdb");

//Create a new OleDB workspacefactory and open the OleDB workspace
OLEDBWorkspaceFactory workspaceFactory = new OLEDBWorkspaceFactory();
IFeatureWorkspace featWorkspace = (IFeatureWorkspace)workspaceFactory.open(propset, 0);
//IFeatureWorkspace featWorkspace = workspaceFactory.open(propset, 0);

//Open a table object
ITable table = featWorkspace.openTable("GDB.MY_TABLE");

This example demonstrates how to open a table from a TextFile data source.

//Create a new textfile workspacefactory and open a textfile workspace
TextFileWorkspaceFactory workspaceFactory = new TextFileWorkspaceFactory();
IFeatureWorkspace featWorkspace = (IFeatureWorkspace)workspaceFactory.openFromFile("./", 0);

//Open a table object
ITable table = featWorkspace.openTable("Sample.txt");