home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Total C++ 2
/
TOTALCTWO.iso
/
borland
/
32snipit.pak
/
TBLLIST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-06
|
3KB
|
80 lines
// BDE32 3.x - (C) Copyright 1996 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)
{
hDBIDb hDb; // Handle to the database
hDBICur hCur; // Handle to the list of tables
UINT16 uNumRecs = 100; // Maximum number of records to
// display
DBIResult rslt; // Return value from IDAPI function
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 ***");
}