Create a New Personal Geodatabase (C++)

Description:

This sample will demonstrate the steps needed to create a new personal geodatabase stored in an .mdb file.

How to use:
  1. Paste the code into your C++ Application.
  2. Call the function from within your application.
//
// createAccessWorkspace
// NOTE:
//   Location does not have to contain ending '\'.  Also name should not contain .mdb extension
//
HRESULT createAccessWorkspace(BSTR location, BSTR name, IWorkspaceName ** ppOutWorkspaceName)
{

	if (ppOutWorkspaceName == NULL)
		return E_POINTER;

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

	return ipWkspFact->Create(location, name, NULL, NULL, ppOutWorkspaceName);

}