When using SQLite in nhib1_1.2, pay attention to the provider of SQLite ado.net.

Source: Internet
Author: User
Tags configuration settings log4net

Finsar. SQLite. sqliteconnection

Situation: I want to store a small amount of data in the database,

2, and use nhib.pdf

Nhib.pdf does not support access well, so I chose to use SQLite. However, the same code can be passed on ms SQL Server, but it does not pass SQLite, step by step, we can find that the SQLite constructor is as follows:

Public sqlitedriver (): Base (
"SQLite. Net ",
"Finsar. SQLite. sqliteconnection ",
"Finsar. SQLite. sqlitecommand ")
{
}

After checking, I used the DLL in http://sourceforge.net/projects/sqlite-dotnet2.

The SQLite DLL used in SQLite in nhib.pdf is actually used.

Http://sourceforge.net/projects/adodotnetsqlite,

Because the DLL is incorrect, the error "cannot create driver from ***" is often reported. When using this version, we should copy the sqlite3.dll to the execution directory, otherwise, an error occurs.

This is the configuration file used when SQLite is used. (Note: This file is only applicable to nhibbench 1.2. For other versions, see this document)

 

<? 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>

<Nhib.pdf>
<! --
<Add key = "hibernate. show_ SQL"
Value = "true"/>
<Add key = "hibernate. Connection. provider"
Value = "nhib.pdf. Connection. driverconnectionprovider"/>

<Add key = "hibernate. dialect"
Value = "nhibect. dialect. mssql2000dialect"/>

<Add key = "hibernate. Connection. driver_class"
Value = "nhib.pdf. 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 = "nhib.pdf. Connection. driverconnectionprovider"/>

<Add key = "hibernate. dialect"
Value = "nhib.pdf. dialect. sqlitedialect"/>

<Add key = "hibernate. Connection. driver_class"
Value = "nhib.pdf. 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"/>


</Nhib.pdf>

<! -- 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] %-5 p % 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 = "rollingfile"/>
</Root>

</Log4net>


</Configuration>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.