zoukankan      html  css  js  c++  java
  • 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; }
  • 相关阅读:
    Git Bash关键命令
    一个不需要Log4Net的写日志的简单方法
    未知软件
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/maoye520/p/11223844.html
Copyright © 2011-2022 走看看