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
- Paste the function in your project.
- 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 |