Dropping a Table

< BACK  NEXT >
[oR]

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   _T("Could not drop table")   endl;       return;   }   cout   _T("Table dropped")   endl; } 

< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net