Supported with: ArcGIS Engine, ArcGIS Desktop, ArcGIS Server
Library dependencies: System, SystemUI, Geometry, Display, Server, Output, GeoDatabase, GISClient, DataSourcesFile
The DataSourcesGDB library contains the implementation of the GeoDatabase API for the database data sources. These data sources include Microsoft Access, File Geodatabases and any RDBMS supported by ArcSDE.
The DataSourcesGDB library is not extended by developers.
The major objects within DataSourcesGDB are workspace factories and the Data Server Manager. 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, feature classes, and relationships. DataSourcesGDB has workspace factories for connecting to Access, File Geodatabase and ArcSDE 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.
The main workspace factories contained within this library are:

An AccessWorkspaceFactory is used to connect to a Microsoft Access database.
The following example shows how to connect to an Access database.
'Create an access workspace factory
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkFactory = New esriDataSourcesGDB.AccessWorkspaceFactory
'Open an access workspace
Dim pFWorkspace As IWorkspace
Set pFWorkspace = pWorkspaceFactory.OpenFromFile("d:\data\access\us_states.mdb", 0)
A FileGDBWorkspaceFactory is used to connect to a File geodatabase. Note that a file Geodatabase is denoted by the gdb extension as opposed to Access workspaces with have an mdb extension.
The following example shows how to connect to a File geodatabase.
'Create a file Geodatabase workspace factory
Dim pWorkspaceFactory As IWorkspaceFactory
Set pWorkFactory = New esriDataSourcesGDB.FileGDBWorkspaceFactory
'Open a file geodatabase
Dim pFWorkspace As IWorkspace
Set pFWorkspace = pWorkspaceFactory.OpenFromFile("d:\data\access\us_states.gdb", 0)
A ScratchWorkspaceFactory is used to connect to a temporary database stored in Microsoft Access. These workspaces are commonly used to hold the results of a selection set. This workspace factory is fundamentally different than the AccessWorkspaceFactory in a couple ways. First, there are interfaces (IScratchWorkspaceFactory and IScratchWorkspaceFactory2) on it to create new temporary workspaces or connect to existing temporary workspaces. Second, when the last reference to the workspace is released, the Access database is automatically deleted from the disk.
The following example shows how to get the current scratch workspace to use as part of a selection.
Dim pScratchWorkspaceFactory2 as IScratchWorkspaceFactory2 Dim pWorkspace as IWorkspace 'Get the current scratch workspace Set pScratchWorkspaceFactory2 = New ScratchWorkspaceFactory Set pWorkspace = pScratchWorkspaceFactory2.CurrentScratchWorkspace 'Select from an existing table using an existing query, 'putting the resulting selection set in the temporary workspace Set pSelSet = pTable.Select(pQuery, esriSelectionTypeHybrid, esriSelectionOptionNormal, pWorkspace)
A SdeWorkspaceFactory is used to connect to an ArcSDE database. There are a few interfaces on this workspace factory that are important to ArcSDE data sources. ISetDefaultConnectionInfo and ISetDefaultConnectionInfo2 are used to specify the username, password, and version of connections to SDE workspaces when those parameters are not specified by the connection properties. This is important if you want to save a connection file that does not persist this information. IRemoteDatabaseWorkspaceFactory is used to maintain connection files. These files, which store the connection properties used to connect to ArcSDE workspaces, commonly have the .sde extension.
The Data Server Manager is used to access and administer one or more Geodatabases stored on a data server using ArcSDE direct connect. You can also create WorkspaceNames from which you can open up Workspaces to these Geodatabases. The following example shows how to connect to a Geodatabase in a Personal ArcSDE for SQL Server using the Data Server Manager.
'Create a Data Server Manager object
Dim pDSManager As IDataServerManager
Set pDSManager = New esriDataSourcesGDB.DataServerManager
'Initialize the data server
pDSManager.ServerName = katahdin\sqlexpress
Connect to the Data Server
pDSManager.Connect
Dim pDSManagerAdmin As IDataServerManagerAdmin
Set pDSManagerAdmin = pDSManager
Create a WorkspaceName to a Geodatabse
Dim pWorkspaceName As IWorkspaceName
Set pWorkspaceName = pDSManagerAdmin.CreateWorkspaceName ("Landbase", dbo.Default)
Dim pName As IName
Dim pWorkspace As IWorkspace
Set pName = pWorkspaceName
Set pWorkspace = pName.Open