// BDE - (C) Copyright 1995 by Borland International // tbllist.c #include "snipit.h" //===================================================================== // Function: // TableList(); // // Description: // This example shows how to get a list of tables that are // in the working directory for the STANDARD database. //===================================================================== void TableList(void) { DBIResult rslt; // Return value from IDAPI function hDBIDb hDb; // Handle to the database hDBICur hCur; // Handle to the list of tables UINT16 uNumRecs = 100; // Maximum number of records to // display Screen("*** Getting a list of available tables ***\r\n"); BREAK_IN_DEBUGGER(); Screen(" Initializing IDAPI..."); if (InitAndConnect(&hDb) != DBIERR_NONE) { Screen("\r\n*** End of Example ***"); return; } Screen(" Setting the database directory..."); rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory); ChkRslt(rslt, "SetDirectory"); Screen(" Get a list of the available tables..."); rslt = DbiOpenTableList(hDb, TRUE, TRUE, NULL, &hCur); ChkRslt(rslt, "OpenTableList"); // If the cursor is valid, display the tables in the working directory. if (rslt == DBIERR_NONE) { Screen(" Display the tables (up to %d)...\r\n", uNumRecs); rslt = DbiSetToBegin(hCur); ChkRslt(rslt, "SetToBegin"); DisplayInMemoryTable(hCur, uNumRecs); rslt = DbiCloseCursor(&hCur); ChkRslt(rslt, "CloseCursor"); } Screen("\r\n Get a list of the available files..."); rslt = DbiOpenFileList(hDb, NULL, &hCur); ChkRslt(rslt, "OpenTableList"); // If the cursor is valid, display the files in the working directory. if (rslt == DBIERR_NONE) { Screen(" Display the files (up to %d)...\r\n", uNumRecs); rslt = DbiSetToBegin(hCur); ChkRslt(rslt, "SetToBegin"); DisplayInMemoryTable(hCur, uNumRecs); rslt = DbiCloseCursor(&hCur); ChkRslt(rslt, "CloseCursor"); } Screen("\r\n Close the database and exit IDAPI..."); CloseDbAndExit(&hDb); Screen("\r\n*** End of Example ***"); }