1 // 2 // MainPage.xaml.cpp 3 // Implementation of the MainPage class. 4 // 5 6 #include "pch.h" 7 #include "MainPage.xaml.h" 8 #include "sqlite3.h" 9 10 using namespace vsixtest; 11 12 using namespace Platform; 13 using namespace Windows::Foundation; 14 using namespace Windows::Foundation::Collections; 15 using namespace Windows::UI::Xaml; 16 using namespace Windows::UI::Xaml::Controls; 17 using namespace Windows::UI::Xaml::Controls::Primitives; 18 using namespace Windows::UI::Xaml::Data; 19 using namespace Windows::UI::Xaml::Input; 20 using namespace Windows::UI::Xaml::Media; 21 using namespace Windows::UI::Xaml::Navigation; 22 23 // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 24 25 MainPage::MainPage() 26 { 27 InitializeComponent(); 28 UseSQLite(); 29 } 30 31 void MainPage::UseSQLite(void) 32 { 33 int rc = SQLITE_OK; 34 sqlite3 *pDb = nullptr; 35 36 rc = sqlite3_open_v2("test.db", &pDb, 37 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr); 38 39 if (rc != SQLITE_OK) 40 throw ref new FailureException("Failed to open database."); 41 42 rc = sqlite3_exec(pDb, "VACUUM;", nullptr, nullptr, nullptr); 43 44 if (rc != SQLITE_OK) 45 throw ref new FailureException("Failed to vacuum database."); 46 47 rc = sqlite3_close(pDb); 48 49 if (rc != SQLITE_OK) 50 throw ref new FailureException("Failed to close database."); 51 52 pDb = nullptr; 53 } 54