一開始我也納悶,我以為是我數據庫沒弄好,但是當我仔細檢查,才發現 原來我少了分號
寫少了分號,可能會導致 database 和 table 找不到。。。
所以用的時候需要注意。。。
代碼部分:
#include "stdafx.h" #include "sqlite3.h" #include <iostream> using namespace std; sqlite3 * pDB = NULL; int _tmain(int argc, _TCHAR* argv[]) { //打開路徑采用utf-8編碼 //如果路徑中包含中文,需要進行編碼轉換
//指定數據庫路徑記得寫全 並加上 分號 " ; "
int nRes = sqlite3_open("D:\\sqlite\\fuck.db;", &pDB); if (nRes != SQLITE_OK) { cout << "Open database fail: " << sqlite3_errmsg(pDB); goto QUIT; } else { cout << "打開數據庫成功!" << endl; } QUIT: sqlite3_close(pDB); return 0; }