在VS2017 C 中快速用上Sqlite

2021-09-05 10:35:48 字數 1128 閱讀 2817

如果我們想編寫乙個有資料庫支援的程式,但是我們又不想安裝資料伺服器,那麼sqlite我們最好的選擇,以前我們還可以選擇微軟的access資料庫檔案mdb,但隨著微軟的office的公升級,mdb的支援也是越來越錯綜複雜了,所以這裡我們為了快速的實現我們的目標,我們選擇了sqlite。

2、通過sqlitestudio建立乙個測試用**

這裡,我們建立了乙個**,testtab,表中有三個欄位id,name,age,隨後輸入幾條記錄即可。

3、在**中呼叫

在編寫**前,記得新增引用**,using system.data.sqlite;

//讀取記錄** 

void loadsqliterecord(int x=0)

//新增記錄**

void insertsqliterecord(string id)

{random ra = new random(20);//這個隨機數不是資料庫呼叫的必要語句

string constr = "data source=../data/mydatabase.db;";

//設定sql查詢語句

string sql = "insert into testtab(id,name,age) values('"+id+"','student0"+ id.trimstart("stu".tochararray())+"','"+ra.next(16,20)+"')";

建立連線物件

sqliteconnection con = new sqliteconnection(constr);

//建立命令物件

sqlitecommand cmd = new sqlitecommand(sql, con);

con.open();

cmd.executenonquery();

con.close();

cmd = null;

con.dispose();

記錄xerces使用(VS2017 C )

1.編譯xerces,獲得dll檔案和lib檔案 2.將dll檔案和lib檔案拷貝到使用xerces的工程目錄裡面去 3.配置vs2017 c c all options additional include directories 放入xerces工程的src目錄 linker all optio...

VS2017 C 讀取Txt資料的方法

目錄 1.這裡採用fopen s 函式開啟檔案。2.對一些有規範格式檔案的讀取,可使用標準庫stdio.h下的fscanf s函式。3.如讀取檔案data.txt 資料格式相對規範 與程式 外的資料 檔案 打交道,我們使用到流 stream 這個概念,實現程序的虛擬記憶體與檔案之間的資料交換。檔案流...

無法編譯 VS2017C 工程編譯問題

1.屬性 init statement 需要編譯器標誌 std c 17 vs2017的時候會出現如下報錯,解決辦法如下 工程屬性 c c 所有選項 c 語言標準 iso c 17標準 std c 17 2.平台公升級 the builds tools for v120 platform tools...