SQLite編程相關

來源:互聯網
上載者:User

   SQLite開源,代碼簡單,功能足夠強大,使用非常廣泛,在這 整理下C/C++對SQLite資料庫編程相關的一些知識。

  一。 SQLite建庫建表

  二。 VS環境下,32位程式使用SQLite的方法

  三。 64位環境下SQLite的使用方法

  VS版本為: VS2012

  SQLite版本: 3080401

  一。 SQLite建庫建表

?

1 2 3 4 5 6 7 8 9 10 11 cd C:sqlite sqlite3.exe mydict.db create table userpwd( id integer primary key autoincrement,pwd varchvar(30));   insert into userpwd(pwd) values ('aaa');   insert into userpwd(pwd) values ('123456');   select * from userpwd;   .quit

  二。 VS環境下,32位程式使用SQLite的方法

  首先下載 sqlite-dll-win32-x86 得到dll與def檔案,然後使用lib.exe手工產生VS所需的 lib 檔案即可在VS環境中使用了。

  1. 從VS IDE下找到mspdb110.dll,複製到lib.exe程式所在目錄下

  mspdb110.dll 存放在下面目錄:

  C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDE

  2. 進入lib.exe所在目錄,運行命令得到lib

  lib.exe所在目錄如下:

  C:Program Files (x86)Microsoft Visual Studio 11.0VCbin

  產生lib的命令:

?

1 2 3 4 5 C:Program Files (x86)Microsoft Visual Studio 11.0VCbin>lib.exe /MACHINE:IX86 /DEF:C:sqlitesqlite3.def /OUT:C:sqlitesqlite3.lib Microsoft (R) Library Manager Version 11.00.60610.1 Copyright (C) Microsoft Corporation.  All rights reserved.      正在建立庫 C:sqlitesqlite3.lib 和對象 C:sqlitesqlite3.exp

  3. 將複製到lib.exe所在目錄的mspdb110.dll給刪除掉,不清理的話在編譯器時會VS會報錯。

  4. 引用標頭檔,lib開始使用資料庫

  #include "sqlite3.h"

  #pragma comment(lib,"sqlite3.lib")

  三。 64位環境下SQLite的使用方法

  SQLite的庫是32位的,所以編譯器成64位時,會有報錯。

  這時通過去官網直接下載SQLite的源碼檔案,將原始碼整合至項目工程中的方式即可使用它。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.