SQLite数据库的增删改查代码
//搜集整理了一下网上的代码.找了半天居然找不到一条插入语句.好郁闷的
//感觉速度还可以.小文件.很多小应用程序在用这个数据库
//SQLite使用办法.直接COPYDLL文件System.Data.SQLite.DLL到应用程序DEBUG目录下。 然后在项目中添加引用,找到这个文件即可
//添加引用
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Data.SQLite;
private static string FavoriteDbPath = System.Environment.CurrentDirectory + "\\Favorite.db";
private bool CreateSQLiteDb()
{
try
{
System.Data.SQLite.SQLiteConnection.CreateFile(FavoriteDbPath);
System.Data.SQLite.SQLiteConnection Conn = new System.Data.SQLite.SQLiteConnection();
System.Data.SQLite.SQLiteConnectionStringBuilder ConnStr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
ConnStr.DataSource = FavoriteDbPath;
ConnStr.Password = "Admin";//设置密码,SQLite ADO.NET实现了数据库密码保护
Conn.ConnectionString = ConnStr.ToString();
Conn.Open();
System.Data.SQLite.SQLiteComman
相关文档:
再说在linux下建立.a 和点so
到网站下载 sqlite-amalgamation-3.6.22.tar.gz 这个包,反正我下了sqlite3-3.6.22.bin.gz解压后编译不了。
解压,运行
# ./configure --host=armv5l-linux --prefix=/opt/sqlite3/arm --enable-threadsafe.
......
sqlite数据库第三方java扩展包下载地址:http://www.zentus.com/sqlitejdbc/
有2个包,一个是nested(嵌入式的),一个是native(本地的)。
区别在于:nested 不需要额外的dll文件,但是速度慢。native需要一个额外的dll文件,速度很快。
1.使用nested包:sqlitejdbc-v037-nested.jar
java代码:
java 代码
packa ......
1:从sqlite的官网上下载源码 http://www.sqlite.org/download.html
2:打开vs2008工程新建一个空的dll工程。
3:把sqlite3.h,sqlite3.cpp,sqlite3.def分别加入到head file 和source file下。
4:编译程序。 这时只能得到sqlite3.dll文件。
5:打开vs2008自带的命令行: 切到sqlite3.def所在的目录。
6:运行 ......
事务(DbTransaction):
SQLite 缺省为每个操作启动一个事务,所以成批插入的时候,启动事务,比不启动事务快n倍。
在没启动事务之前往Sqlite数据库里插入1000多条数据的情况,结果每次都需要一两分钟才能完成.
而在启动事物以后所需要的时间直接变成不到2秒!原来sqlite花两分钟是由于ExecuteNonQuery方法执行时自己提交 ......
本文以数据库中的数据表UserInfo为实例展示数据库表的创建及数据记录的录入。
#!/bin/sh
#variables definition
#database location
db=/conf/db
#
#create table userInfo
#name: User name
#passwd: Password
#Privilege: User privilege -- Administrator:0 Operator:1
#
echo "create table UserInfo(n ......