UserName Property Example (VC++)

This example sets the access permissions for a table named MyTable in the specified database for a user named Millicent to read-only. The code then checks to see if Millicent has permission to add records.

CdbDBEngine      dbeng;
CdbWorkspace   wrkDefault;
CdbDatabase      dbsNorthwind;
CdbDocument      docMyTable;

wrkDefault = dbeng.Workspaces[0L];
dbsNorthwind = wrkDefault.OpenDatabase(_T("Northwind.mdb"));

docMyTable = dbsNorthwind.Containers[_T("Tables")][_T("MyTable")];
docMyTable.SetUserName(_T("Millicent"));
docMyTable.SetPermissions(dbSecRetrieveData);
if (docMyTable.GetPermissions() & dbSecInsertData)
  printf(_T("Millicent can insert data"));
else
 printf(_T("Millicent can't insert data"));
...