显示具有 Sqlite 标签的文章。 显示所有文章
显示具有 Sqlite 标签的文章。 显示所有文章

2007年10月24日 星期三

在.NET中使用Sqlite的解决方案

使用正确的Wrapper将使得在C#中使用Sqlite更加方便。半年前试图在C#中通过调用普通DLL的方法使用Sqlite,比较繁琐。这里又一个phpguru的SQLite.NET wrapper,使用起来和Visual Studio自带的库能很自然的结合。

开发文档:
http://www.phpguru.org/static/SQLite.NET.html

下载:
http://www.phpguru.org/downloads/csharp/SQLite.NET/

使用范例:

using SQLite.NET;


Open



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:


ArrayList tables = db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'");

foreach (string tableName in tables)
{
Console.WriteLine("\t" + tableName);
}
 
(L)1984 - 2007 TONY CHEUNG