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. [幽默漫画]对于程序猿来说deadline很容易搞定!

     更多漫画在这里

  2. Google想出了一个决定人员晋升的算法,然后就没有然后了......

    Google 有点跑偏了,逗死我了~实践一下也好~ Prasad Setty 是 Google People Analytics 团队的副总裁.7 年前 Google 成立的这支团队的职责是收集和利用 ...

  3. SpringBoot添加对Mybatis分页插件PageHelper的支持

    1.修改maven配置文件pom.xml,添加对pageHelper的支持: <!--pagehelper--> <dependency> <groupId>com ...

  4. Unity3d 屏幕截图。并保存。iOS

    - ( void ) imageSaved: ( UIImage *) image didFinishSavingWithError:( NSError *)error contextInfo: ( ...

  5. 10分钟精通require.js

    require.js的诞生,就是为了解决这两个问题:(1)实现js文件的异步加载,避免网页失去响应:(2)管理模块之间的依赖性,便于代码的编写和维护. 实例下载:require.js应用实例 一.re ...

  6. C/S通信模型与B/S通信模型介绍

    1.客户端与服务器之间的通信模型 基于Socket连接的客户端与服务器之间的通信模型图如上图所示,整个通信过程如下所示: (1) 服务器端首先启动监听程序,对指定的端口进行监听,等待接收客户端的连接请 ...

  7. SQL语句 怎么把从一个表中查出来数据插入到另一个表中

    (1).select * into destTbl from srcTbl(2).insert into destTbl(fld1, fld2) select fld1, 5 from srcTbl

  8. miniOrm

    PetaPoco.Core https://www.nuget.org/packages/PetaPoco.Core/5.1.228

  9. 变址values(, %edi, 4)和间址4(%edi)

    <汇编语言程序设计>Richard Blum著:5.2.4 在内存和寄存器之间传送数据   使用变址的内存位置: 可以在一个命令中指定把多个值存放到内存中: values:     .in ...

  10. JavaWeb应用项目部署到云ubuntu

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6383068.html 在前面的博文中,我们已经在云主机ubuntu上搭建好jdk.tomcat以及mysql了 ...