Use of SQLite in Windows Mobile Development

Source: Internet
Author: User

as an open-source database, SQLite has been widely used on iOS, Android, and other platforms. It is much more efficient than Microsoft's sqlce in terms of operating efficiency, you can compare the performance on the Internet.
reference blog:
http://www.cnblogs.com/egmkang/archive/2009/07/12/1521997.html
using SQLite on WM and installation:
1. first download and install the Program , some are the EXE installation package, some are the zip package, and some are the major files in the zip package.
decompress SQLite in the compareframework directory under the bin directory. the interop.066.dll file is stored in the corresponding project folder of the WM device or the WM simulator.
set the system in the bin directory. data. SQLite. load the DLL file to vs2008, that is, add reference. If a Windows Mobile project is developed, vs2008 should add the referenced system. Data. SQLite. dll file from the compareframework directory under the bin directory.
2. You also need an SQLite management tool. There are many management tools. I use sqlitespy_1.9.1.
3. Use the SQLite program as follows:
Code :

// Save dataset data to the SQLite database // The directory where the WM project is running string Path = path. getdirectoryname (system. reflection. assembly. getexecutingassembly (). getname (). codebase) + "\ test. db3 "; sqliteconnection conn = new sqliteconnection (" Data Source = "+ path); Conn. open (); sqlitecommand cmd = Conn. createcommand (); // The insert operation uses the transaction sqlitetransaction Tx = Conn. begintransaction (); cmd. transaction = TX; try {foreach (datarow row in DS. ta Bles ["users"]. rows) {string SQL = "insert into users (name, age) values ('" + row [0] + "', '" + row [1] + "') "; cmd. commandtext = SQL; cmd. executenonquery ();} Tx. commit (); MessageBox. show ("data inserted successfully !! ");} Catch (system. Data. SQLite. sqliteexception e) {Tx. rollback (); MessageBox. Show (" failed to insert data !! ");} Finally {Conn. close ();} ------------------------------------------------------------------------------ // insert data conn quickly. open (); string sql1 = "insert into users (name, age) values ('hello', 23)"; sqlitecommand cmd = new sqlitecommand (sql1, Conn); cmd. executenonquery (); -------------------------------------------------------------------------------- // read data and display try {string sql2 = "select * from users"; Conn. open (); sqlitedataadapter adapter = new sqlitedataadapter (sql2, Conn); datatable able = new datatable (); adapter. fill (datatable); datagrid1.datasource = datatable;} catch (exception e) {console. writeline (E. tostring ();} finally {Conn. close ();}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.