blob: e67dcb83b23dc363124addc4d5c9e91d54e2f769 [file] [log] [blame]
mistachkinc32db462016-02-25 02:49:58 +00001//
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
10using namespace vsixtest;
11
12using namespace Platform;
13using namespace Windows::Foundation;
14using namespace Windows::Foundation::Collections;
15using namespace Windows::UI::Xaml;
16using namespace Windows::UI::Xaml::Controls;
17using namespace Windows::UI::Xaml::Controls::Primitives;
18using namespace Windows::UI::Xaml::Data;
19using namespace Windows::UI::Xaml::Input;
20using namespace Windows::UI::Xaml::Media;
21using 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
25MainPage::MainPage()
26{
27 InitializeComponent();
28 UseSQLite();
29}
30
31void 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}