1. 下载SQLite 引擎及.net Provider. 地址:http://sqlite.phxsoftware.com/
2. 在项目添加对"System.Data.SQLite.dll"及"RaisingStudio.DAC.dll"的引用。
3. 在项目下创建名为"providers.config"的xml文件,内容配置如下:
代码
<?xml version="1.0" encoding="utf-8"?>
<providers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<clear/>
<provider name="SQLite"
description="SQLite, System.Data.SQLite Interop Library v1.0.65.0"
enabled="true"
assemblyName="System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=1fdb50b1b62b4c84"
connectionClass="System.Data.SQLite.SQLiteConnection"
commandClass="System.Data.SQLite.SQLiteCommand"
parameterClass="System.Data.SQLite.SQLiteParameter"
parameterDbTypeClass="System.Data.DbType, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac"
parameterDbTypeProperty="DbType"
dataAdapterClass="System.Data.SQLite.SQLiteDataAdapter"
commandBuilderClass="System.Data.SQLite.SQLiteCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
setDbParameterPrecision="false"
setDbParameterScale="false"
allowMARS="false"
/>
</providers>
<providers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<clear/>
<provider name="SQLite"
description="SQLite, System.Data.SQLite Interop Library v1.0.65.0"
enabled="true"
assemblyName="System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=1fdb50b1b62b4c84"
connectionClass="System.Data.SQLite.SQLiteConnection"
commandClass="System.Data.SQLite.SQLiteCommand"
parameterClass="System.Data.SQLite.SQLiteParameter"
parameterDbTypeClass="System.Data.DbType, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac"
parameterDbTypeProperty="DbType"
dataAdapterClass="System.Data.SQLite.SQLiteDataAdapter"
commandBuilderClass="System.Data.SQLite.SQLiteCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
setDbParameterPrecision="false"
setDbParameterScale="false"
allowMARS="false"
/>
</providers>
*注意:根据引用的System.Data.SQLite.dll的版本的不同,作相应修改。
4. 添加名为"connections.config"的配置文件:内容:
代码
<?xml version="1.0" encoding="utf-8" ?>
<connections>
<connection providerName="SQLite">Data Source=\Program Files\SmartDeviceProject3\Data\sqlite.db;Pooling=true;FailIfMissing=false</connection>
</connections>
<connections>
<connection providerName="SQLite">Data Source=\Program Files\SmartDeviceProject3\Data\sqlite.db;Pooling=true;FailIfMissing=false</connection>
</connections>
5. 编译,运行。*注意:运行时,需将"SQLite.Interop.065.DLL"(注意版本),"providers.config","connection.config"及相应的数据库文件复制到运行目录下.
示例:下载
参见:http://dac.codeplex.com/WorkItem/View.aspx?WorkItemId=4034