Advertisement
bkuhns

C++/CX, WinRT, PPL, and C all in one snippet!

Oct 10th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1.     create_task(
  2.         KnownFolders::DocumentsLibrary->CreateFileAsync(
  3.             L"KatchupDatabase.kat",
  4.             CreationCollisionOption::OpenIfExists
  5.         )
  6.     ).then([&](StorageFile^ file) {
  7.         if(!file) {
  8.             throw task_canceled("Unable to create database file.");
  9.         }
  10.  
  11.         wstring wfilePath = file->Path->Data();
  12.         string filePath;
  13.         filePath.assign(begin(wfilePath), end(wfilePath));
  14.  
  15.         char* err = nullptr;
  16.         sqlite3* db = nullptr;
  17.         sqlite3_open(filePath.c_str(), &db);
  18.         auto rc = sqlite3_exec(db, "CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);", nullptr, nullptr, &err);
  19.         if(rc != SQLITE_OK) {
  20.             cout << err << endl;
  21.             sqlite3_free(err);
  22.         }
  23.         sqlite3_close(db);
  24.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement