This example creates a new Workspace and appends it to the Workspaces collection. It assumes that the user JustAUser with a password of Secret has already been created. The example enumerates the collections of each Workspace object and finally closes the new Workspace. See the methods and properties of the Workspace object or Workspaces collection for additional examples.
CdbDBEngine dbeng;
CdbWorkspace wrkNew, wrkEnum;
CdbDatabase db;
int nWrk, nDb, nUsr, nGrp;
// Open the database.
db = dbeng.OpenDatabase(_T("Northwind.mdb"));
// Create new workspace and add it to collection.
wrkNew = dbeng.CreateWorkspace("NewWorkspace", "JustAUser", "");
dbeng.Workspaces.Append(wrkNew);
// Enumerate all workspaces.
for (nWrk = 0; nWrk < dbeng.Workspaces.GetCount(); nWrk++)
{
wrkEnum = dbeng.Workspaces[nWrk];
printf("\nEnumeration of Workspaces(%d): %s\n", nWrk, wrkEnum.GetName());
// Enumerate databases.
printf("Databases: Name\n");
for (nDb = 0; nDb < wrkEnum.Databases.GetCount(); nDb++)
printf(" %s\n", wrkEnum.Databases[nDb].GetName());
// Enumerate all user accounts.
printf("Users: Name\n");
for (nUsr = 0; nUsr < wrkEnum.Users.GetCount(); nUsr++)
printf(" %s\n", wrkEnum.Users[nUsr].GetName());
// Enumerate all group accounts.
printf("Groups: Name\n");
for (nGrp = 0; nGrp < wrkEnum.Groups.GetCount(); nGrp++)
printf(" %s\n", wrkEnum.Groups[nGrp].GetName());
}
// Enumerate built-in properties of wrkNew.
printf("wrkNew.Name: %s\n", wrkNew.GetName());
printf("wrkNew.UserName: %s\n", wrkNew.GetUserName());
wrkNew.Close();