Dropping a Table

Tables, including the data they contain, can be dropped through the TablesPtr collection. In Listing 16.4 a catalog is opened and a TablesPtr interface pointer obtained. The name of the table to be dropped ("Customers") is set into a VARIANT containing a BSTR, and the TablesPtr interface function Delete is used to drop the table.

Listing 16.4. Dropping a table
 void Listing16_4() { AdoXNS::_CatalogPtr pCatalog; AdoXNS::TablesPtr pTables; AdoXNS::_TablePtr pTable; HRESULT hr; if(!OpenCatalog(lpConnection, pCatalog)) return; // get collection of tables pTables = pCatalog->GetTables(); // Specify table to drop _bstr_t bstrTable(_T("Customers")); _variant_t varTable(bstrTable); hr = pTables->Delete(varTable); if(FAILED(hr)) { cout ...

Get Windows® CE 3.0 Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.