D**u 发帖数: 288 | 1 本人.net菜鸟,因为暂时用不了SQL Server,想把一些数据存在SQLITE里。在
Stackoverflow
上看到大家推荐 System.Data.SQLite,
觉得很不错,不过在VS2010 Professional和VS2012 Express 和VS2012 Ultimate上都
没有试成功,恳请指点。
我的code是参考这个网站上的
http://www.techcoil.com/blog/my-experience-with-system-data-sql
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string dbConnectionString = @"Data Source=sample.s3db";
SQLiteConnection sqliteCon = new SQLiteConnection(
dbConnectionString);
sqliteCon.Open();
string createAppUserTableSQL = "CREATE TABLE [AppUser] (" +
"[name] TEXT NULL," +
"[username] TEXT NULL" +
")";
using (SQLiteTransaction sqlTransaction = sqliteCon.
BeginTransaction())
{
SQLiteCommand createCommand = new SQLiteCommand(
createAppUserTableSQL, sqliteCon);
createCommand.ExecuteNonQuery();
createCommand.Dispose();
sqlTransaction.Commit();
}
sqliteCon.Close();
}
}
}
错误是:
Could not load file or assembly 'System.Data.SQLite, Version=1.0.84.0,
Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies
. An attempt was made to load a program with an incorrect format.
在下多谢了!!! |
c*********e 发帖数: 16335 | 2 首先,你要在reference里把System.Data.SQLite加进去,光
using System.Data.SQLite是不够的。
【在 D**u 的大作中提到】 : 本人.net菜鸟,因为暂时用不了SQL Server,想把一些数据存在SQLITE里。在 : Stackoverflow : 上看到大家推荐 System.Data.SQLite, : 觉得很不错,不过在VS2010 Professional和VS2012 Express 和VS2012 Ultimate上都 : 没有试成功,恳请指点。 : 我的code是参考这个网站上的 : http://www.techcoil.com/blog/my-experience-with-system-data-sql : using System; : using System.Collections.Generic; : using System.Linq;
|
D**u 发帖数: 288 | |
D**u 发帖数: 288 | 4 补充点信息,现在的是刚下在的VS Ultimate 2012 30 天trial version, .net4.5。所
以安装了
Precompiled Binaries for 64-bit Windows (.NET Framework 4.5)
sqlite-netFx45-binary-bundle-x64-2012-1.0.84.0.zip |
c*********e 发帖数: 16335 | 5 你下载的System.Data.SQLite是哪个版本:1.0.66.0 version,or 1.0.84.0?
【在 D**u 的大作中提到】 : 恩,加了的,code里面都没有下划线
|
D**u 发帖数: 288 | 6 sqlite-netFx45-binary-bundle-x64-2012-1.0.84.0.zip |
D**u 发帖数: 288 | 7 成了,hoho
换了一个
Precompiled Statically-Linked Binaries for 64-bit Windows (.NET Framework 4.
5)
之前的是 Precompiled Binaries 不行。
然后这次换了一个错误Unable to load DLL 'SQLite.Interop.dll': The specified
module could not be found. (Exception from HRESULT: 0x8007007E)
然后google到这个
http://stackoverflow.com/questions/13028069/unable-to-load-dll-
再按照这个方法
following steps:
Open the project designer in Visual Studio.
Click on the Build tab.
Disable the prefer 32-bit option.
就可以用了
convergence 谢谢你哈,以后再向你请教
居然就可以用了,晕,也不知道为啥Precompiled Binaries 不行。 |
D**u 发帖数: 288 | 8 难道key是 Disable the prefer 32-bit option |