我有越來越SQLite的在我的C#IRC bot的工作問題。System.Data.Sqlite問題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;
using System.IO;
namespace ModBot
{
class Database
{
private SQLiteConnection myDB;
private SQLiteCommand cmd;
public Database()
{
InitializeDB();
}
private void InitializeDB()
{
if (File.Exists("ModBot.db"))
{
Console.WriteLine("HEYOOOOOOO");
myDB = new SQLiteConnection("Data Source=ModBot.db;Version=3;");
String sql = "CREATE TABLE IF NOT EXISTS twitch (id INTEGER PRIMARY KEY, user TEXT, currency INTEGER DEFAULT 0, subscriber INTEGER DEFAULT 0, btag TEXT DEFAULT null);";
cmd = new SQLiteCommand(sql, myDB);
cmd.ExecuteNonQuery();
}
else
{
Console.WriteLine("YOOHOOOOO");
SQLiteConnection.CreateFile("ModBot.db");
myDB = new SQLiteConnection("Data Source=ModBot.db;Version=3;");
String sql = "CREATE TABLE IF NOT EXISTS twitch (id INTEGER PRIMARY KEY, user TEXT, currency INTEGER DEFAULT 0, subscriber INTEGER DEFAULT 0, btag TEXT DEFAULT null);";
cmd = new SQLiteCommand(sql, myDB);
cmd.ExecuteNonQuery();
}
}
}
}
我下載了System.Data.Sqlite,並將它作爲資源添加到我的項目中。當運行的代碼,它將引發DllNotFound異常(具體是:無法加載DLL「SQLite.Interop.dll」:指定的模塊找不到(從HRESULT異常:0x8007007E)),當它試圖使實際連接。
任何想法?
你確定你的目標正確的平臺? http://stackoverflow.com/questions/4744293/unable-to-load-dll-sqlite3-the-specified-module-could-not-be-found-exceptio – wgraham
您是否正確粘貼? – AAlferez
@wgraham:我不確定如何使用Visual C#2010更改目標平臺。但我嘗試過使用x86和x64 SQLite dll。與任何一個相同的錯誤。 – Keirathi