This document is archived and information here might be outdated.  Recommended version.


How to connect to a personal geodatabase (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Appendix: ArcObjects in Visual C++ > Samples > Geodatabase > Accessing data > How to connect to a personal geodatabase

How to connect to a personal geodatabase


Making a connection to a workspace is the foundation to accessing data. This sample will show you how to connect to a personal geodatabase stored in an .mdb file. The example code is a function that takes the path to the personal geodatabase as a string and returns a workspace.

How to use

  1. Paste the function in your project.
  2. Call the function from your code.
[VCPP]
//
// openAccessWorkspace:  connect to a personal geodatabase
// connString should be full path to the access database with .mdb extension
// example "c:\temp\geodata.mdb"
//
HRESULT openAccessWorkspace(BSTR connString, IWorkspace **outWorkspace)
{

  HRESULT hr;
  CComPtr < IWorkspaceFactory > ipWorkspaceFactory;
  ipWorkspaceFactory.CoCreateInstance(CLSID_AccessWorkspaceFactory);

  return ipWorkspaceFactory->OpenFromFile(connString, NULL, outWorkspace);
}






Development licensing Deployment licensing
Engine Developer Kit Engine