Finisar.SQLite.SQLiteConnection
情况:我想存储少量的数据,在数据库,
2,并且使用nhibernate
nhibernate对access的支持算不上好,所以我就选择使用了sqlite,但是同样的代码在ms sql server上能通过但就是就对sqlite通过不过,通过一步,步地跟踪发现sqlite的构造函数是如下的情况
public SQLiteDriver() : base(
"SQLite.NET",
"Finisar.SQLite.SQLiteConnection",
"Finisar.SQLite.SQLiteCommand")
{
}
经检查是我使用了http://sourceforge.net/projects/sqlite-dotnet2这里的dll
而nhibernate中sqlite中使用的sqlite的dll却是使用的
http://sourceforge.net/projects/adodotnetsqlite的这个版本,
因为dll不对,所以经常出现不能 could not create driver from ***这个错误,在使用这个版本的时候,我们应将SQLite3.dll这个dll拷贝到执行目录下,不然的话,会出错
这是使用sqlite时用到的配置文件,(注,只适用于nhibernate 1.2版本,其它版本请不要参考)
<?
xml version
=
"
1.0
"
encoding
=
"
utf-8
"
?>
< configuration >
< configSections >
< section name = " nhibernate " type = " System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089 " />
< section name = " log4net " type = " log4net.Config.Log4NetConfigurationSectionHandler,log4net " />
</ configSections >
< nhibernate >
<!--
< add key = " hibernate.show_sql "
value = " true " />
< add key = " hibernate.connection.provider "
value = " NHibernate.Connection.DriverConnectionProvider " />
< add key = " hibernate.dialect "
value = " NHibernate.Dialect.MsSql2000Dialect " />
< add key = " hibernate.connection.driver_class "
value = " NHibernate.Driver.SqlClientDriver " />
< add key = " hibernate.connection.connection_string "
value = " Server=.cxy;database=mytest;uid=sa;pwd=cxy " />
-->
< add key = " hibernate.show_sql "
value = " true " />
< add key = " hibernate.connection.provider "
value = " NHibernate.Connection.DriverConnectionProvider " />
< add key = " hibernate.dialect "
value = " NHibernate.Dialect.SQLiteDialect " />
< add key = " hibernate.connection.driver_class "
value = " NHibernate.Driver.SQLiteDriver " />
< add key = " hibernate.connection.connection_string "
value = " Data Source=cxy.db;Version=3 " />
< add key = " hibernate.query.substitutions "
value = " true=1;false=0 " />
</ nhibernate >
<!-- This section contains the log4net configuration settings -->
< log4net >
<!-- Define some output appenders -->
< appender name = " rollingFile " type = " log4net.Appender.RollingFileAppender,log4net " >
< param name = " File " value = " log.txt " />
< param name = " AppendToFile " value = " true " />
< param name = " RollingStyle " value = " Date " />
< param name = " DatePattern " value = " yyyy.MM.dd " />
< param name = " StaticLogFileName " value = " true " />
< layout type = " log4net.Layout.PatternLayout,log4net " >
< param name = " ConversionPattern " value = " %d [%t] %-5p %c [%x] <%X{auth}> - %m%n " />
</ layout >
</ appender >
<!-- Setup the root category, add the appenders and set the default priority -->
< root >
< priority value = " ALL " />
< appender - ref ref = " rollingFile " />
</ root >
</ log4net >
</ configuration >
< configuration >
< configSections >
< section name = " nhibernate " type = " System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089 " />
< section name = " log4net " type = " log4net.Config.Log4NetConfigurationSectionHandler,log4net " />
</ configSections >
< nhibernate >
<!--
< add key = " hibernate.show_sql "
value = " true " />
< add key = " hibernate.connection.provider "
value = " NHibernate.Connection.DriverConnectionProvider " />
< add key = " hibernate.dialect "
value = " NHibernate.Dialect.MsSql2000Dialect " />
< add key = " hibernate.connection.driver_class "
value = " NHibernate.Driver.SqlClientDriver " />
< add key = " hibernate.connection.connection_string "
value = " Server=.cxy;database=mytest;uid=sa;pwd=cxy " />
-->
< add key = " hibernate.show_sql "
value = " true " />
< add key = " hibernate.connection.provider "
value = " NHibernate.Connection.DriverConnectionProvider " />
< add key = " hibernate.dialect "
value = " NHibernate.Dialect.SQLiteDialect " />
< add key = " hibernate.connection.driver_class "
value = " NHibernate.Driver.SQLiteDriver " />
< add key = " hibernate.connection.connection_string "
value = " Data Source=cxy.db;Version=3 " />
< add key = " hibernate.query.substitutions "
value = " true=1;false=0 " />
</ nhibernate >
<!-- This section contains the log4net configuration settings -->
< log4net >
<!-- Define some output appenders -->
< appender name = " rollingFile " type = " log4net.Appender.RollingFileAppender,log4net " >
< param name = " File " value = " log.txt " />
< param name = " AppendToFile " value = " true " />
< param name = " RollingStyle " value = " Date " />
< param name = " DatePattern " value = " yyyy.MM.dd " />
< param name = " StaticLogFileName " value = " true " />
< layout type = " log4net.Layout.PatternLayout,log4net " >
< param name = " ConversionPattern " value = " %d [%t] %-5p %c [%x] <%X{auth}> - %m%n " />
</ layout >
</ appender >
<!-- Setup the root category, add the appenders and set the default priority -->
< root >
< priority value = " ALL " />
< appender - ref ref = " rollingFile " />
</ root >
</ log4net >
</ configuration >