易截截图软件、单文件、免安装、纯绿色、仅160KB

C#与Sqlite数据库操作实例

这是一个有关分页的实例,仅供参考(代码来自网络)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Threading;
using System.Collections;
using System.IO;
namespace ReadCardDemo
{
public partial class Form3 : Form
{
Form4 form4 = new Form4();
int pageSize = 12; //每页显示行数
int nMax = 0; //总记录数
int totalPage = 0; //总页数=总记录数/每页显示行数
int currentPage = 1; //当前页号
int pageCount = 0; //当前页数的记录数
int selectRow; //当前选中的行数
DataSet dataSet = new DataSet();
DataTable dataTable = new DataTable();
SQLiteDataAdapter dataAdapter;
SQLiteConnection conn = new SQLiteConnection();
SQLiteCommand cmd;
SQLiteDataReader dr;
string datasource;
string _sql;
public Form3()
{
InitializeComponent();
}
//初始化数据
public void InitializeDataSource()
{
dataTable.Clear();
dataTable.AcceptChanges();
//创建数据库
//datasource = "/Windows/ReadCardDemo/PersonId.db";
//SQLiteConnection.CreateFile(datasource);
//建立数据库连接
datasource = @"Data Source=/Windows/ReadCardDemo/PersonId.db";
conn.ConnectionString = datasource;
//获取当前数据库的记录数
_sql = "select count(*) from PersonId";
conn.Open();
cmd = new SQLiteCommand(_sql, conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
try
{
nMax = Convert.ToInt32(dr.GetValue(0));
}
catch(Exception e)
{


相关文档:

SQLite快速入门

    SQLite小巧的特点使其在嵌入式上利用很广泛。越来越多的移动设备上加入了SQLite模块,android,sysmbian, iphone,...下面的介绍让你快速步入SQLite的大门。
1. 下载
    SQLite是开源的项目,所以你可以下载完速的源代码。开发的时候你可以把源代码嵌入你的工程当中,也可以用编译 ......

Using SQLite from Shell in Android

Where is SQLite?
SQLite is available on the Android device itself. The executable is in the /system/bin directory of the device. You can see that this directory contains the shell commands like ls, ps, etc., as well as sqlite3, dalvikvm, and dexdump utilities.
Code Listing 1. Contents of system/ ......

我们一起学习 sqlite 的应用


                                                       ......

SQLite 中文 FAQ

zz from https://www.dream4ever.org/showthread.php?t=86440 feuvan @ DRL
原文在http://sqlitecn.feuvan.net/faq.html
语法部分正在翻译中,敬请期待
FAQ中文版
如何创建自增字段?
SQLite 支持哪些数据类型?
为什么能向 SQLite 数据库的整型字段中插入字符串?
为什么 SQLite 认为表达式 '0'=='00' 为真? ......

Sqlite判断字段存在

判断表存在的方法很简单,网上很多:
SELECT COUNT(*) from sqlite_master where type='table' and name='%s'" % tname;
那么判断字段是否存在, 或者说如何判断表的版本是否最新就只需要:
select * from sqlite_master where tbl_name='tblContactList';
sqlite_master 的表结构如下:
type   |name  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号