实际上目前已经有很好的sqlite的.net支持。
发布的时候只需要携带一个库文件就可以。
从这里下载
http://sourceforge.net/projects/sqlite-dotnet2/files/
下载之后安装。 在安装目录下面的bin文件夹下的System.Data.SQLite.dll就是类库。 拷贝到你的.net应用目录。在引用中添加
为了创建数据库, 我们还需要类似access那样的管理程序。
这里推荐
http://sqliteadmin.orbmu2k.de/
免费, 还好用。 其他的也有很多, 一搜一大把。
可以用这个程序创建出s3db文件数据库。
然后就是代码, 和Oledb基本一样的。
using System.Data.SQLite;
SQLiteConnection sqlite_conn;
SQLiteDataAdapter sqlite_adpter;
SQLiteCommandBuilder sqlite_cmdbuilder;
public Form1()
{
InitializeComponent();
sqlite_conn = new SQLiteConnection(@"Data Source="+ Application.StartupPath+@"/TestDB.s3db");
sqlite_adpter = new SQLiteDataAdapter("select * from HelloWorld", sqlite_conn);
sqlite_cmdbuilder = new SQLiteCommandBuilder(sqlite_adpter);
}