Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQLite3 database read and write

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

/ / insert data # include "CppSQLite3.h" # include CppSQLite3DB db;BOOL re = _ access ("config.db", 0); / / determine whether the file exists if (re! =-1) / / equal to-1 means that {db.open ("config.db") does not exist; CppSQLite3Buffer bufSQL; bufSQL.format ("insert into UserManage (UserName) values (% Q)", W2A (strName)) TRACE (_ T ("% s"), CString ((const char*) bufSQL)); db.execDML (bufSQL);} else {AfxMessageBox (_ T ("File does not exist!");} / / query CppSQLite3DB db;db.open ("C:\\ config.db"); CppSQLite3Query Q = db.execQuery ("select * from userManage"); for (int fld = 0; fld < q.numFields () Fld++) {TRACE (_ T ("% s\ n"), CString (q.fieldName (fld));} while (! q.eof ()) {TRACE (_ T ("% s force% s department% s\ n"), CString (q.fieldValue (0)), CString (q.fieldValue (1)), CString (q.fieldValue (2)); q.nextRow ();}

When creating a table, use the SQLite Developer tool to set the encoding format to ANSI, otherwise garbled will occur when reading.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report