C Examples: DbiAddPassword

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

C Examples: DbiAddPassword

Return to chapter overview

Create a table with a password and add that password to the current session.

If phCur is not NULL, return an open cursor. This example uses the following input:
         fDbiAddPassword(hDb, &hTmpCur, "BORLAND C");

DBIResult fDbiAddPassword(hDBIDb hDb, phDBICur phCur, pCHAR pPWD)

{

   DBIResult   rslt;

   CRTblDesc   TblDesc;

   FLDDesc     fldDesc[] = {{ // Field 1 - ALPHA

               1, "MyAlpha", fldZSTRING, fldUNKNOWN, 10, 0,

               0, 0, 0, fldvNOCHECKS, fldrREADWRITE

               }};

 

   memset((void *) &TblDesc, 0, sizeof(CRTblDesc));

   lstrcpy(TblDesc.szTblName, "COBRA.DB");

   TblDesc.iFldCount = 1;

   TblDesc.pfldDesc = fldDesc;

   TblDesc.bProtected = TRUE;

   lstrcpy(TblDesc.szPassword, pPWD);

 

   rslt = Chk(DbiAddPassword(pPWD));

   if (rslt != DBIERR_NONE)

      return rslt;

 

   rslt = Chk(DbiCreateTable(hDb, TRUE, &TblDesc));

   if (rslt != DBIERR_NONE)

      return rslt;

 

   if (phCur != NULL)

     rslt = Chk(DbiOpenTable(hDb, TblDesc.szTblName, NULL, NULL, NULL, NULL,

                 dbiREADWRITE, dbiOPENSHARED, xltFIELD, FALSE, NULL, phCur));

 

   return rslt;

}