Board index » delphi » Problem adding aliases to IDAPI 16-Bit

Problem adding aliases to IDAPI 16-Bit

I am having a problem with adding aliases to IDAPI.  For discussion sake let
s assume that we are working with 16-Bit IDAPI and the name of the
configuration file is C:\IDAPI\IDAPI.CFG.  What seems to be happening is
theres a copy of IDAPI.CFG on disk and theres a copy of IDAPI.CFG in
memory.  The problem is that the two copies dont always match.  Follow the
procedure below to duplicate the problem:

1. Start up BDECFG (Borland 16-Bit IDAPI configuration program).

2. Create a new alias called JUNK

3. Save the configuration and exit BDECFG

4. Start up BDECFG and verify that JUNK is still there and then close
BDECFG.

5. Execute my little test application.  My app will add two aliases
(MYALIAS1  & MYALIAS2).  The code for it is listed below.  You will notice
that its pretty simple.  The first loop searches for existence of MYALIAS1
& MYALIAS2.  If either is found they are deleted.  After that, MYALIAS1 &
MYALIAS2 are added back in.

int main()
{
hDBICur     hCur;
 CURProps    TblProps;       // Table properties
 pBYTE       pRecBuf;        // Record buffer
 DBINAME     szDatabase;     // String to contain the driver name
 BOOL        bIsBlank;       // Is the field blank?
 DBDesc      dbDesc;         // Database descriptor

 CHKERR(DbiInit(NULL));

 CHKERR(DbiOpenDatabaseList(&hCur));

 CHKERR(DbiGetCursorProps(hCur, &TblProps));

 pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize * sizeof(BYTE));
 if (pRecBuf == NULL)
  {
  printf("Could not allocate memory","Error");
  CHKERR(DbiCloseCursor(&hCur));
  CHKERR(DbiExit());
  }

  CHKERR(DbiSetToBegin(hCur));

  while (DbiGetNextRecord(hCur, dbiNOLOCK, pRecBuf, NULL) == DBIERR_NONE)
  {
    CHKERR(DbiGetField(hCur, 1, pRecBuf, (pBYTE) szDatabase, &bIsBlank));
    CHKERR(DbiGetDatabaseDesc(szDatabase, &dbDesc));
    // Display the information about the database.
    if ((strcmp(dbDesc.szName,"MYALIAS1")==0) ||
    (strcmp(dbDesc.szName,"MYALIAS2")==0))
     DbiDeleteAlias(NULL, dbDesc.szName);
  }

  // Clean up.
  free(pRecBuf);
  CHKERR(DbiCloseCursor(&hCur));

 CHKERR(DbiAddAlias(NULL, "MYALIAS1", szPARADOX, "PATH:C:\\",TRUE));
 CHKERR(DbiAddAlias(NULL, "MYALIAS2", szPARADOX, "PATH:C:\\",TRUE));
 CHKERR(DbiExit());

 return 0;

Quote
}

6. Start up BDECFG and view the aliases.  You will notice that JUNK is
missing.

What seems to have happened is that the copy of IDAPI.CFG in memory didnt
know anything about JUNK in the first place (i.e. it doesnt match whats
on disk).  Thus when my test application was executed, it overwrote
IDAPI.CFG on diskette with IDAPI.CFG in memory ? JUNK alias gets lost.

I need a way of telling my test application to get a fresh copy of IDAPI.CFG
from disk.  That way, I am sure that no aliases will get removed.

 

Re:Problem adding aliases to IDAPI 16-Bit


Mike,

Your message is almost unreadable as certain characters have become
garbled. I think the problem is at your end as other messages (so far)
are ok. It might be worth a repost.

Incidentally, there are a number of freeware alias managers around,
with source, if you want to study how others have tackled alias related
problems. If I can help, come back.

Bob
--

Using Virtual Access
http://www.vamail.com

Other Threads