C++用sqlite3_open連接打開指定數據庫的小問題


一開始我也納悶,我以為是我數據庫沒弄好,但是當我仔細檢查,才發現 原來我少了分號

寫少了分號,可能會導致  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; }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM