小智 67
我和布鲁斯在一起.我使用http://system.data.sqlite.org/也取得了巨大的成功.这是我创建的一个简单的类示例:
using System;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace MySqlLite
{
class DataClass
{
private SQLiteConnection sqlite;
public DataClass()
{
//This part killed me in the beginning. I was specifying "DataSource"
//instead of "Data Source"
sqlite = new SQLiteConnection("Data Source=/path/to/file.db");
}
public DataTable selectQuery(string query)
{
SQLiteDataAdapter ad;
DataTable dt = new DataTable();
try
{
SQLiteCommand cmd;
sqlite.Open(); //Initiate connection to the db
cmd = sqlite.CreateCommand();
cmd.CommandText = query; //set the passed query
ad = new SQLiteDataAdapter(cmd);
ad.Fill(dt); //fill the datasource
}
catch(SQLiteException ex)
{
//Add your exception code here.
}
sqlite.Close();
return dt;
}
}
Run Code Online (Sandbox Code Playgroud)
还有一个NuGet包:System.Data.SQLite可用.
bva*_*erw 12
我用这个非常成功:
http://system.data.sqlite.org/
免费,没有任何限制.
(请注意:原始网站不再存在.上面的链接有一个指向404网站的链接,并且包含原始的所有信息)
--Bruce
在http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers上有一个.Net的Sqlite包装器列表.从我所听到的http://sqlite.phxsoftware.com/非常好.这个特殊的允许您通过ADO.Net访问Sqlite,就像任何其他数据库一样.
归档时间: |
|
查看次数: |
93116 次 |
最近记录: |