// BDE - (C) Copyright 1995 by Borland International // qbe.c #include "snipit.h" //===================================================================== // Function: // QBE(); // // Description: // This example shows how to do a QBE query on a Paradox table. //===================================================================== void QBE (void) { DBIResult rslt; // Return value from IDAPI functions hDBIDb hDb; // Handle to the database hDBICur hCur; // Cursor to the result set from the query // Query string CHAR szQry[] = { "CUSTOMER.DB | Name | Phone |\r\n" " | Check | Check |" }; Screen("*** 'Query by Example' Example ***\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(" Perform the following query on the table:\r\n"); Screen(szQry); // The DbiQExecDirect function sets up the query, executes // the query, and returns a cursor to the answer table. Screen("\r\n Do a direct query of the table..."); rslt = DbiQExecDirect(hDb, qrylangQBE, szQry, &hCur); if (ChkRslt(rslt, "QExecDirect") != DBIERR_NONE) { CloseDbAndExit(&hDb); Screen("\r\n*** End of Example ***"); return; } // Check for a valid cursor. if (hCur) { Screen(" Display the first 10 records in the answer table"); rslt = DbiSetToBegin(hCur); ChkRslt(rslt, "SetToBegin"); DisplayTable(hCur, 10); Screen("\r\n Close the cursor to the answer set..."); rslt = DbiCloseCursor(&hCur); ChkRslt(rslt, "CloseCursor"); } else { Screen(" Error - Could not get cursor to the answer table"); } Screen(" Close the database and exit IDAPI..."); CloseDbAndExit(&hDb); Screen("\r\n*** End of Example ***"); }