易截截图软件、单文件、免安装、纯绿色、仅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,然后得出的结论是:SQLite 效率太低,批量插入1000条记录,居然耗时 2 分钟!
下面是他发给我的测试代码。我晕~~~~~~ 
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
// 创 ......

SQLite如何删除、修改、重命名列?

首先声明:如果你想直接alter,放弃吧。以下内容可以忽略了。
sqlite官方说明如下:
SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, o ......

sqlite性能优化

主要通过pragma指令来实现。
比如: 空间释放、磁盘同步、Cache大小等。
不要打开。前文提高了,Vacuum的效率非常低!
PRAGMA auto_vacuum;
PRAGMA auto_vacuum = 0 | 1;
查询或设置数据库的auto-vacuum标记。
正常情况下,当提交一个从数据库中删除数据的事务时,数据库文件不改变大小。未使用的文件页被标记并在以 ......

sqlite全文查询配置到使用全过程

      SQLite是一款轻型的数据库,是遵守ACID的关联式数据库管理系统,它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了。它能够支持Windows/Linux/Unix等等主流的操作系统,同时能够跟很多程序语言相结合,比 ......

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号