win8 应用商店程序使用SQLITE数据库
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数据库的更多相关文章
- C#程序使用SQLite数据库
转至 http://www.cnblogs.com/redmoon/archive/2006/12/09/587617.html System.Data.SQLite(SQLite ADO.NET 2 ...
- sqlite数据库如何远程连接?
sqlite数据库如何远程连接代码如下:QSqlDatabase db =QSqlDatabase::addDatabase("QSQLITE"); db.setHostName( ...
- Android基础------SQLite数据库(一)
1.SQLite介绍 SQLite是一款非常流行的嵌入式数据库,它支持SQL操作,并且只用很少的内存. Android在运行时集成了SQLite,所有每个Android应用程序都可以使用SQLLite ...
- RT/Metro商店应用如何调用SQLite数据库
RT/Metro商店应用如何调用SQLite数据库 使用前,要安装:SQLite for Windows Runtime (Windows 8.1)(一个VS插件).还有Visual C++ Runt ...
- 转:使用log4net完成程序异常日志记录(使用SQLite数据库记录和普通文本记录)
http://www.cnblogs.com/kyo-yo/archive/2010/06/11/use-log4net-to-log-exception.html 在前端时间开发的时候由于需要将异常 ...
- 在Android程序中使用已有的SQLite数据库
已经将这篇文章迁移至 Code问答,你也能够到这里查看这篇文章,请多多关注我的新技术博客CodeWenDa.com 在中文搜索中,没有找到一篇比較好的关于怎样在Android应用中使用自己事先创建好的 ...
- 在 Android 应用程序中使用 SQLite 数据库以及怎么用
part one : android SQLite 简单介绍 SQLite 介绍 SQLite 一个非常流行的嵌入式数据库.它支持 SQL 语言,而且仅仅利用非常少的内存就有非常好的性能.此外它还是开 ...
- C#/Sqlite-单机Window 程序 sqlite 数据库实现
数据库分析和选择 Excel 文件 做数据源 限制性比较强,且不适合查询,分析 等操作 Access 数据库 Access 管理数据界面和功能不强 mysql 和sql server 功能满足,但需要 ...
- 【Android】13.0 第13章 创建和访问SQLite数据库—本章示例主界面
分类:C#.Android.VS2015: 创建日期:2016-02-26 一.简介 Android 内置了三种数据存取方式:SQLite数据库.文件.SharedPreferences. 这一章我们 ...
随机推荐
- python之simplejson,Python版的简单、 快速、 可扩展 JSON 编码器/解码器
python之simplejson,Python版的简单. 快速. 可扩展 JSON 编码器/解码器 simplejson Python版的简单. 快速. 可扩展 JSON 编码器/解码器 编码基本的 ...
- phpmyadmin误删表后如何恢复
用mysqlbinlog php处理代码: 将mysql-bin.xxxxxx文件导出为可读文本: <?php //导出mysql-bin.000xxx文件为可读性txt文本 //0为执行成功, ...
- css背景全屏-视差
<!DOCTYPE html> <html> <head> <title></title> <style> *{margin:0 ...
- MVC 之 System.Web.Optimization找不到引用
在MVC4的开发中,如果创建的项目为空MVC项目,那么在App_Start目录下没有BundleConfig.cs项的内容,在手动添加时在整个库中都找不到:System.Web.Optimizatio ...
- vsphere脚本等
- 深度学习-Windows平台下的Caffe编译教程
一.安装CUDA7.5 Cuda是英伟达推出的GPU加速运算平台 我这里安装的是cuda7.5,已经安装过的忽略,还没有安装过的这里有安装教程.windows下面安装还是非常简单的. https:// ...
- stingray前端架构总体设计及运行过程
SPA 单页应用程序,在一个页面内用ajax技术实现所有的功能的web程序,我们称之为单页应用,明显的特点就是第一次加载之后地址栏非参数部分不再发生变化.大家观察会发现 WIP系统就是一个SPA.我们 ...
- Page Visibility实现焦点丢失提醒
0.前言 HTML5 Page Visibility API是一个很实用的特性.当页面对用户不可见时,暂停播放页面中的视频.动画.声音.以及其它耗费内存的操作,等用户回来时.再继续这些操作. 当然,最 ...
- django之创建第8-1个项目-数据库之增删改查/数据库数据显示在html页面
1.为test.DB数据库预先创建下面数据 1 张三 16 2015-01-02 12 李四 17 2015-01-04 13 王五 14 ...
- iOS 瀑布流之栅格布局
代码地址如下:http://www.demodashi.com/demo/14760.html 一 .效果预览 二.确定需求 由下面的需求示意图可知模块的最小单位是正方形,边长是屏幕宽除去边距间隔后的 ...