在.NET C#中使用sqlite
sqlite是最近比较火的一个小型embeddable RDBMS。 用C实现的,开源,memory footprint非常小,而且对不同的语言有很多wrapper支持。在.NET中使用sqlite,其实很简单,主要是找个.NET的wrapper。看了几个,最终选了phpguru的SQLite.NET
把sqlite.dll和SQLiteClient.dll放在.NET的current path下面,在项目的references中添加SQLiteClient.dll
程序中引用
c# 代码
[*]using SQLite.NET;
使用方法,打开db:
c# 代码
[*]try
[*] {
[*] Console.WriteLine("opening db...");
[*] // Open database
[*] SQLiteClient db = new SQLiteClient("c:\test.db");
[*]
[*] }
[*] catch (SQLiteException e)
[*] {
[*] Console.WriteLine("Fatal error: {0}", e.Message);
[*] return;
[*] }
select应用:
c# 代码
[*]ArrayList tables = db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'");
[*]
[*] foreach (string tableName in tables)
[*] {
[*] Console.WriteLine("\t" + tableName);
[*] }
其他update,insert,delete都支持得不错。 sqlite小巧玲珑,用起来十分方便。
Google Gears和Adobe AIR都在使用sqlite,看来必有其过人之处。。。
页:
[1]