在nhibernate 1.2 中使用sqlite时应注意sqlite的ado.net的提供者

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] &lt;%X{auth}&gt; - %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 >
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值