Codsmith软件下载页面:http://www.ibeifeng.com/down.php?id=36606
SQLite驱动下载页面:http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
Navicat for SQLite管理工具下载页面:http://www.pc6.com/softview/SoftView_57268.html
下载三个驱动文件:
http://system.data.sqlite.org/downloads/1.0.82.0/sqlite-netFx40-setup-bundle-x86-2010-1.0.82.0.exe
实际上只要装此集合包就行了,装之前关闭VS2010 , 之后打开服务器资源管理器 -> 添加连接
http://system.data.sqlite.org/downloads/1.0.82.0/sqlite-netFx40-setup-x86-2010-1.0.82.0.exe
http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/(选择最新版本的SQLite-1.0.66.0-setup.exe下载)
下载: SQLite-1.0.66.0-setup.exe
C开发环境中 ,需要下载sqlite源码包, 其中引入 sqlite3.c、sqlite.h即可
下载: sqlite-amalgamation-3071400.zip
//创建一个数据库文件
//string datasource = "d:/test.db";
//System.Data.SQLite.SQLiteConnection.CreateFile(datasource);
//连接数据库
SQLiteConnection conn = new SQLiteConnection();
SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
connstr.DataSource = "E:/test/test.db";
//connstr.Password = "admin";//设置密码,SQLite ADO.NET实现了数据库密码保护
conn.ConnectionString = connstr.ToString();
conn.Open();
//创建表
//SQLiteCommand cmd = new SQLiteCommand();
//string sql = "CREATE TABLE test(username varchar(20),password varchar(20))";
//cmd.CommandText = sql;
//cmd.Connection = conn;
//cmd.ExecuteNonQuery();
//插入数据
SQLiteCommand cmd = new SQLiteCommand();
string sql = "INSERT INTO userinfo VALUES(10, 'lcd', '123456')";
cmd.CommandText = sql;
cmd.Connection = conn;
cmd.ExecuteNonQuery();
//取出数据
sql = "SELECT * FROM userinfo";
//select c.rowid from userinfo可以获取到数据库行id
cmd.CommandText = sql;
SQLiteDataReader reader = cmd.ExecuteReader();
String username = "";
String password = "";
while (reader.Read())
{
username = reader.GetString(1);
password = reader.GetString(2);
}
MessageBox.Show(username + ";" + password);