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. 这一章我们 ...
随机推荐
- C语言常见问题 如何用Visual Studio编写C语言程序测试
新建Win32控制台应用程序 勾选控制台空项目 右击源文件,添加cpp文件 输入范例代码,可以正常运行#include <stdio.h> int main(void) { i ...
- android中使用toolbar
系统默认使用的是ActionBar,就是界面中的标题栏,但是由于ActionBar设计的原因,被限定只能位于活动的顶部,从而不能实现Material Design效果,所以官方建议使用Toolbar替 ...
- 从C++到java
C++和java都号称是面向对象的语言,虽然C++不完全算是.学习过C++如何快速对java有个大体的掌握,可以通过对比来进行了解. 首先还是来高大上一下,看看他们的使命: · C++ 被设计成主要用 ...
- 关于extern "C"(详细剖析)
[目录] 引言 extern “C”的前世今生 小心门后的未知世界 Q&A c++调用c的方法 c调用c++的方法 在你工作过的系统里,不知能否看到类似下面的代码. 这好像没有什么问题,你应该 ...
- 微信小程序 - 图片懒加载
wxml <!-- 数据源 --> <view class='item-{{index}}' wx:for="{{lazyData}}" wx:key=" ...
- 开发JAVA9以上的项目时,出现ClassNotFoundException: javax.xml.bind.JAXBException的解决方法
一.问题描述: 开发JAVA9以上的项目时,出现ClassNotFoundException: javax.xml.bind.JAXBException的解决方法 二.问题样例 三.解决方案 打开mv ...
- Azure Paas SQL 修改用户名密码的相关问题
现总结如下,供您参考: 1) 如何单独修改每个数据库的密码? 在portal中,我们提供了一个最高权限的,可管理服务器下所有数据库的服务器用户 跟密码,但在实际使用中,由于权限过大,会有潜在的安全隐 ...
- 单页面SPA应用路由原理 history hash
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- Ulua_toLua_基本案例(八)_LuaAccessingArray
Ulua_toLua_基本案例(八)_LuaAccessingArray using UnityEngine; using LuaInterface; public class AccessingAr ...
- WIN10-修改网卡MAC
在注册表位置: 计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002 ...