当前位置:Gxlcms > 数据库问题 > 关于C#中“配置”sqlite问题

关于C#中“配置”sqlite问题

时间:2021-07-01 10:21:17 帮助过:2人阅读

去除这个警告,只要在解决方案,右击,属性,生成,把anycpu改为X86,即OK!

第二个问题是运行sqlite语句,如连接

using (SQLiteConnection con = new SQLiteConnection(ConnStr))
{
con.Open();
using (SQLiteCommand com = new SQLiteCommand())
{
com.Connection = con;
com.CommandText = "insert into T_Login values(‘2015‘,‘2015‘)";
com.ExecuteNonQuery();
}
}

则会出现:“System.IO.FileLoadException”类型的未经处理的异常在 PresentationCore.dll

解决方法:

Paste the following XML inside the configuration tag:

  <startup useLegacyV2RuntimeActivationPolicy="true">     <supportedRuntime version="v4.0"/>   </startup>

其实只要往原有的<startup>标签中加入useLegacyV2RuntimeActivationPolicy="true" 即OK。

 

sqlite连接语句:最简单的,直接给个路径 string ConnStr = @"Data Source=C:\\zhj.db";

在configuration tag 中:

<connectionStrings>
<add name="dbConnStr" connectionString="Data Source=C:\\zhj.db;Pooling=true;FailIfMissing=false"/>
</connectionStrings>

关于C#中“配置”sqlite问题

标签:

人气教程排行