http://www.cnblogs.com/zhuzhenyu/archive/2012/11/27/2790193.html

using SQLite;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation; // “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上有介绍 namespace beelinechinese
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class sqldemo : Page
{
public sqldemo()
{
this.InitializeComponent();
} private void Button_Click(object sender, RoutedEventArgs e)
{
using (var db = CreateSQLiteConnection())
{ //创建表 db.CreateTable<Person>(); }
} private SQLiteConnection CreateSQLiteConnection()
{ //数据文件保存的位置 var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db3.sqlite"); //打开创建数据库和表 return new SQLite.SQLiteConnection(dbPath);
} private void dgfgf_Click(object sender, RoutedEventArgs e)
{ var db =CreateSQLiteConnection(); //单条插入语句 db.Insert(new Person() { ID=System.Guid.NewGuid().ToString(), FirstName = "liufei", LastName = "Sky" });
db.Close();
} private void Button_Click_1(object sender, RoutedEventArgs e)
{
var db = CreateSQLiteConnection();
List<object> list = db.Query(new TableMapping(typeof(Person)), "select * from Person");
db.Close();
List<Person> ml = list.Cast<Person>().ToList();
txtmsg.Text = ml[].FirstName;
} private void Button_Click_2(object sender, RoutedEventArgs e)
{
try
{
var db = CreateSQLiteConnection();
// db.Delete<Person>(new Person() { FirstName = "lisa" }); SQLiteCommand cmd = db.CreateCommand("delete from person where FirstName = 'lisa'"); cmd.ExecuteNonQuery();
db.Close(); }
catch (Exception ex)
{
txtmsg.Text = ex.ToString();
} } private void Button_Click_3(object sender, RoutedEventArgs e)
{
var db = CreateSQLiteConnection();
SQLiteCommand cmd = db.CreateCommand("update person set FirstName='lisa'where FirstName='liufei'"); cmd.ExecuteNonQuery();
db.Close();
}
} public class Person
{ [SQLite.PrimaryKey] public string ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; }
public DateTime LastLogin { get; set; } public string NickName { get; set; } public bool ShowPic { get; set; } }
}
using SQLite;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation; // “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上有介绍 namespace beelinechinese
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class sqldemo : Page
{
public sqldemo()
{
this.InitializeComponent();
} private void Button_Click(object sender, RoutedEventArgs e)
{
using (var db = CreateSQLiteConnection())
{ //创建表 db.CreateTable<Person>(); }
} private SQLiteConnection CreateSQLiteConnection()
{ //数据文件保存的位置 var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db3.sqlite"); //打开创建数据库和表 return new SQLite.SQLiteConnection(dbPath);
} private void dgfgf_Click(object sender, RoutedEventArgs e)
{ var db =CreateSQLiteConnection(); //单条插入语句 db.Insert(new Person() { ID=System.Guid.NewGuid().ToString(), FirstName = "liufei", LastName = "Sky" });
db.Close();
} private void Button_Click_1(object sender, RoutedEventArgs e)
{
var db = CreateSQLiteConnection();
List<object> list = db.Query(new TableMapping(typeof(Person)), "select * from Person");
db.Close();
List<Person> ml = list.Cast<Person>().ToList();
txtmsg.Text = ml[].FirstName;
} private void Button_Click_2(object sender, RoutedEventArgs e)
{
try
{
var db = CreateSQLiteConnection();
// db.Delete<Person>(new Person() { FirstName = "lisa" }); SQLiteCommand cmd = db.CreateCommand("delete from person where FirstName = 'lisa'"); cmd.ExecuteNonQuery();
db.Close(); }
catch (Exception ex)
{
txtmsg.Text = ex.ToString();
} } private void Button_Click_3(object sender, RoutedEventArgs e)
{
var db = CreateSQLiteConnection();
SQLiteCommand cmd = db.CreateCommand("update person set FirstName='lisa'where FirstName='liufei'"); cmd.ExecuteNonQuery();
db.Close();
}
} public class Person
{ [SQLite.PrimaryKey] public string ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; }
public DateTime LastLogin { get; set; } public string NickName { get; set; } public bool ShowPic { get; set; } }
}

win8 应用商店程序使用SQLITE数据库的更多相关文章

  1. C#程序使用SQLite数据库

    转至 http://www.cnblogs.com/redmoon/archive/2006/12/09/587617.html System.Data.SQLite(SQLite ADO.NET 2 ...

  2. sqlite数据库如何远程连接?

    sqlite数据库如何远程连接代码如下:QSqlDatabase db =QSqlDatabase::addDatabase("QSQLITE"); db.setHostName( ...

  3. Android基础------SQLite数据库(一)

    1.SQLite介绍 SQLite是一款非常流行的嵌入式数据库,它支持SQL操作,并且只用很少的内存. Android在运行时集成了SQLite,所有每个Android应用程序都可以使用SQLLite ...

  4. RT/Metro商店应用如何调用SQLite数据库

    RT/Metro商店应用如何调用SQLite数据库 使用前,要安装:SQLite for Windows Runtime (Windows 8.1)(一个VS插件).还有Visual C++ Runt ...

  5. 转:使用log4net完成程序异常日志记录(使用SQLite数据库记录和普通文本记录)

    http://www.cnblogs.com/kyo-yo/archive/2010/06/11/use-log4net-to-log-exception.html 在前端时间开发的时候由于需要将异常 ...

  6. 在Android程序中使用已有的SQLite数据库

    已经将这篇文章迁移至 Code问答,你也能够到这里查看这篇文章,请多多关注我的新技术博客CodeWenDa.com 在中文搜索中,没有找到一篇比較好的关于怎样在Android应用中使用自己事先创建好的 ...

  7. 在 Android 应用程序中使用 SQLite 数据库以及怎么用

    part one : android SQLite 简单介绍 SQLite 介绍 SQLite 一个非常流行的嵌入式数据库.它支持 SQL 语言,而且仅仅利用非常少的内存就有非常好的性能.此外它还是开 ...

  8. C#/Sqlite-单机Window 程序 sqlite 数据库实现

    数据库分析和选择 Excel 文件 做数据源 限制性比较强,且不适合查询,分析 等操作 Access 数据库 Access 管理数据界面和功能不强 mysql 和sql server 功能满足,但需要 ...

  9. 【Android】13.0 第13章 创建和访问SQLite数据库—本章示例主界面

    分类:C#.Android.VS2015: 创建日期:2016-02-26 一.简介 Android 内置了三种数据存取方式:SQLite数据库.文件.SharedPreferences. 这一章我们 ...

随机推荐

  1. Python连接MySQL的实例代码

    Python连接MySQL的实例代码   MySQLdb下载地址:http://sourceforge.net/projects/mysql-python/ 下载解压缩后放到%Python_HOME% ...

  2. redis 五种数据结构详解(string,list,set,zset,hash),各种问题综合

    redis 五种数据结构详解(string,list,set,zset,hash) https://www.cnblogs.com/sdgf/p/6244937.html redis 与 spring ...

  3. MySql 分区 分库 分表

    ubuntu下MySQL配置和管理:http://www.2cto.com/database/201306/222510.html mysql分表,分区的区别和联系:http://my.oschina ...

  4. Objective-C编程 - 1. 浅谈内存分配

    Objective-C语言的对象类型都必须用指针,对象所占的内存是在堆(heap)上分配的. NSString也必须在堆上分配,因此必须用指针. NSString *someString = @&qu ...

  5. js - 关于循环

    ES5:for,foreach,for..in ES6:for..of // ES5(可参见ES6的析构写法) const value = ["a", "b", ...

  6. Unbuntu和Centos中部署同时多版本PHP的详细过程

        镜像制作:Unbuntu14 部署LAMP过程 1.Azure经典版中创建源Ubuntu14,并使用Xshell连接,并切换到root帐户下. 2.安装php5.4,新建/var/local/ ...

  7. JAVA设计模式(全部)

    一篇一篇的重写意义不大,不如把整个PDF文档上传上来看着方便,下载链接

  8. js 数组 转为树形结构

    题目: source = [{ id: 1, pid: 0, name: 'body' }, { id: 2, pid: 1, name: 'title' }, { id: 3, pid: 2, na ...

  9. ES6学习笔记九:修饰器

    一:修饰器(Decorator)是一个函数,用来修改类的行为. 1)定义与使用 function 修饰器名(target) { //target是被修饰对象,可用target.xxx进行调用修改 } ...

  10. nginx 监听一个端口同时支持https和http

    nginx 如何想同时支持https和http,必须监听两个不同的端口,比如http:listen 80; https:listen 443;   server { listen 1234 ssl;s ...