Windows Phone Nine, SQLite database

Source: Internet
Author: User
Tags sqlite database

Using the SQLite database

Installing the SQLite for Windows Phone 8.1 plugin
New Windows Phone 8.1 project
Add SQLite for Windows Phone 8.1 reference
Because the component relies on Microsoft Visual C + + for Windows Phone, it also references the Microsoft Visual C + + runtime package for Windows Phone
Right-click to manage Nuget package references
Search for sqlite-net and install

1      Public class Person2     {3 [PrimaryKey, AutoIncrement]4          Public intId {Get;Set; }5[MaxLength (8)]6          Public stringName {Get;Set; }7          Public intAge {Get;Set; }8          Public CharGender {Get;Set; }9}
Person
1         Private voidButton_Click (Objectsender, RoutedEventArgs e)2         {3             //CREATE DATABASE (no presence created, open if present)4             varConnection =NewSqliteconnection ("temp.db");5             //Create a table6Connection. Createtable<person>();7Person Zhang =NewPerson ();8             //Zhang. Id = 1;9Zhang. Name ="Letter Zhang";TenZhang. Age = -; OneZhang. Gender ='male'; A             //Add Data -             varresult = connection. Insert (Zhang);//returns the number of rows affected by the execution result - System.Diagnostics.Debug.WriteLine (result); the             //Update Action -result = connection. Update (Newperson {Id =2, Name ="Zhangsan", age = + }); - System.Diagnostics.Debug.WriteLine (result); -             //reading Data +             vartemp = connection. Find<person> (1); - System.Diagnostics.Debug.WriteLine (temp. Name); +             //Read all data A             varList = connection. Query<person> ("SELECT * from person where id>=?",1); at             foreach(varIteminchlist) -             { - System.Diagnostics.Debug.WriteLine (item. Name); -             } -             //Delete Operation -Connection. Delete<person> (1); in}

Windows Phone Nine, SQLite database

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.