关于sqlite数据库在使用过程中应该注意以下几点

 

1:使用sqlite数据库,经常会出现数据库连接不上的情况,这个时候需要检查sqlite.dll是否添加了引用,且添加的dll的版本与所使用的sqlite版本是否一致。

   这两个dll是使用sqlite必须要添加的引用,

 

2:为了不使sqlite发布后,找不到数据库,需要手动设置这两个dll自动拷贝到本地。

                右击-》属性-》

 

3:发布的网站记得在Web.config 文件下添加以下节点才能正确访问到sqlite数据库

 <system.data>
  <DbProviderFactories>
   <remove invariant="System.Data.SQLite" />
   <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
  </DbProviderFactories>
 </system.data>

4:数据库放在app_data目录下,发布时引用文件的地址为,不至于是绝对路径无法访问:

<connectionStrings>
  <add name="dbEntities" connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl;provider=System.Data.SQLite;provider connection string=&quot;data source=|DataDirectory|\db.db&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings>

 

5:今天配置一台x64的机器时,报sqlite的错误,“Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. 试图加载格式不正确的程序。”

一开始总以为是sqlite数据库连接不上或是dll版本的问题,后来才发现,System.Data.SQLite是分了操作系统版本的,有X86,X64之分;因此应用程序池应该选择兼容WIN32;

错误截图:

具体操作如下:
在iis管理器,选中应用程序池-》对正在使用的应用程序池 点击 高级设置   -》启用32位应用程序 为 true.

 

这时刷新页面  错误解除。

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目录 sqlite_array_query —— 发送一条 SQL 查询,并返回一个数组。 sqlite_busy_timeout —— 设置超时时间(busy timeout duration),或者频繁的用户失去权限(disable busy handlers)。 sqlite_changes —— 返回被最新的SQL 查询(changed by the most recent SQL statement)改变的行数。 sqlite_close —— 关闭一个打开SQLite数据库sqlite_column —— 在当前的行取得一列(a column from the current row of a result set)。 sqlite_create_aggregate —— Register an aggregating UDF for use in SQL statements。 sqlite_create_function —— Registers a "regular" User Defined Function for use in SQL statements。 sqlite_current —— 在返回的数组取得当前的行(the current row from a result set as an array)。 sqlite_error_string —— 返回错误代码的原始描述(the textual description of an error code)。 sqlite_escape_string —— 释放一个用于查询的字符串(Escapes a string for use as a query parameter)。 sqlite_fetch_array —— 取得下一行并设置成一个数组(the next row from a result set as an array)。 sqlite_fetch_single —— 取得第一列并设置成一个字符串(Fetches the first column of a result set as a string)。 sqlite_fetch_string —— sqlite_fetch_single()的别名。 sqlite_field_name —— 取得结果指定字段的字段名。 sqlite_has_more —— 返回是否有更多可用的行(whether or not more rows are available)。 sqlite_last_error —— 返回数据库的最新的错误代码(the error code of the last error for a database)。 sqlite_last_insert_rowid —— 返回最新插入的行的行号(the most recently inserted row)。 sqlite_libencoding —— 返回SQLite库(SQLite library)的编码(encoding)。 sqlite_libversion —— 返回SQLite库(SQLite library)的版本。 sqlite_next —— 返回下一行的行号。 sqlite_num_fields —— 取得结果集字段的数目。 sqlite_num_rows —— 取得结果集行的数目。 sqlite_open —— 打开一个SQLite数据库。如果文件不存在则尝试创建之。 sqlite_popen —— 用永久连接的方式打开一个SQLite数据库。如果文件不存在则尝试创建之。 sqlite_query —— 发送一条 SQL 查询,并返回一个结果句柄(a result handle)。 sqlite_rewind —— 倒回第一行(Seek to the first row number)。 sqlite_seek —— 在缓存结果查找特定的行号(Seek to a particular row number of a buffered result set)。 sqlite_udf_decode_binary —— Decode binary data passed as parameters to an UDF。 sqlite_udf_encode_binary —— Encode binary data before returning it from an UDF。 sqlite_unbuffered_query —— 发送一条 SQL 查询,并不获取和缓存结果的行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值