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. 这一章我们 ...
随机推荐
- performSelector 多个参数
[self performSelector:@selector(callFooWithArray) withObject:[NSArray arrayWithObjects:@"first& ...
- 微信小程序 - tab选项卡(组件)
更新日期: 2019/3/5:首次发布,默认下标“curIndex”超出红色提示 2019/3/7:增加tabName,可自定义数据标题名称(详情看示例) 支持单个/多个tab(显示/隐藏) 参数: ...
- Python3中使用Mysql的用法。
一.Python2中一般使用MySqldb来调用Mysql,但是在Python3中不支持该包,使用pymysql来代替了,用法一模一样. 二.安装: pip install pymysql 三.例子: ...
- C#中添加三个线程同时启动执行某一方法,并依次调用某方法中的循环打印输。
添加三个线程同时启动执行某一方法,并依次调用某方法中的打印输:ABC ABC ABC ABC 实现代码如下: using System; using System.Collections.Generi ...
- Jaspersoft Studio 导出PDF格式中文不显示
1:设置字体 2:应用上面设置的字体
- linux2.6.30.4内核移植(5)——构建根文件系统(yaffs文件系统格式的镜像)
一.首先编译并安装BusyBox 这里使用的交叉编译器还是3.4.5. 注意:编译内核.编译BusyBox以及编译文件系统中的所有应用程序的交叉编译器要使用同一个版本. 1.获取BusyBox源码 下 ...
- Dwr 框架简单实例
Dwr 是一个 Java 开源库,帮助你实现Ajax网站. 它可以让你在浏览器中的Javascript代码调用Web服务器上的Java,就像在Java代码就在浏览器中一样. Dwr 主要包括两部分: ...
- wwindows文件放入linux后多出换行符
将 windows文件移到linux系统下会在文件行末尾多了一个换行符^M 使用命令cat -v tmp.c可以看到每行后边有^M字符 为了解决这个问题,我们用如下命令:touch love_tmp. ...
- GDALBuildVRT异构波段的支持
目录 简述 修改源码 1.修改DatasetProperty结构体 2.修改VRTBuilder::AnalyseRaster函数 3.修改VRTBuilder::CreateVRTNonSepara ...
- Java Web自定义MVC框架详解 (转)
转自:http://blog.csdn.net/jackfrued/article/details/42774459 最近给学生讲Java Web,希望他们能够在学完这部分内容后自己实现一个MVC框架 ...