s kumar

s kumar

  • NA
  • 32
  • 78.4k

how to solve Sqlite.interop.dll in c#?

Jan 9 2015 5:34 AM

hi,

   Actually I am getting Internet Web History in c#.net windows application. Now I added SQLite.dll in my project library.

Then I added my code
 

public List<URL> URLs { get; set; }

public Form1()

{

InitializeComponent();

GetHistory();

}

public IEnumerable<URL> GetHistory()

{

// Get Current Users App Data

string documentsFolder = Environment.GetFolderPath

(Environment.SpecialFolder.ApplicationData);

// Move to Firefox Data

documentsFolder += "\\Mozilla\\Firefox\\Profiles\\";

// Check if directory exists

if (Directory.Exists(documentsFolder))

{

// Loop each Firefox Profile

foreach (string folder in Directory.GetDirectories

(documentsFolder))

{

// Fetch Profile History

return ExtractUserHistory(folder);

}

}

return null;

}

IEnumerable<URL> ExtractUserHistory(string folder)

{

// Get User history info

DataTable historyDT = ExtractFromTable("moz_places", folder);

// Get visit Time/Data info

DataTable visitsDT = ExtractFromTable("moz_historyvisits",

folder);

// Loop each history entry

foreach (DataRow row in historyDT.Rows)

{

// Select entry Date from visits

var entryDate = (from dates in visitsDT.AsEnumerable()

where dates["place_id"].ToString() == row["id"].ToString()

select dates).LastOrDefault();

// If history entry has date

if (entryDate != null)

{

// Obtain URL and Title strings

string url = row["Url"].ToString();

string title = row["title"].ToString();

// Create new Entry

URL u = new URL(url.Replace('\'', ' '),

title.Replace('\'', ' '),

"Mozilla Firefox");

// Add entry to list

URLs.Add(u);

}

}

// Clear URL History

DeleteFromTable("moz_places", folder);

DeleteFromTable("moz_historyvisits", folder);

return URLs;

}

void DeleteFromTable(string table, string folder)

{

SQLiteConnection sql_con;

SQLiteCommand sql_cmd;

// FireFox database file

string dbPath = folder + "\\places.sqlite";

// If file exists

if (File.Exists(dbPath))

{

// Data connection

sql_con = new SQLiteConnection("Data Source=" + dbPath +

";Version=3;New=False;Compress=True;");

// Open the Conn

sql_con.Open();

// Delete Query

string CommandText = "delete from " + table;

// Create command

sql_cmd = new SQLiteCommand(CommandText, sql_con);

sql_cmd.ExecuteNonQuery();

// Clean up

sql_con.Close();

}

}

DataTable ExtractFromTable(string table, string folder)

{

SQLiteConnection sql_con;

SQLiteCommand sql_cmd;

SQLiteDataAdapter DB;

DataTable DT = new DataTable();

// FireFox database file

string dbPath = folder + "\\places.sqlite";

// If file exists

if (File.Exists(dbPath))

{

// Data connection

sql_con = new SQLiteConnection("Data Source=" + dbPath +

";Version=3;New=False;Compress=True;");

// Open the Connection

sql_con.Open();

sql_cmd = sql_con.CreateCommand();

// Select Query

string CommandText = "select * from " + table;

// Populate Data Table

DB = new SQLiteDataAdapter(CommandText, sql_con);

DB.Fill(DT);

// Clean up

sql_con.Close();

}

return DT;

}

}

public class URL

{

string url;

string title;

string browser;

public URL(string url, string title, string browser)

{

this.url = url;

this.title = title;

this.browser = browser;

}

}

Throws an error after ran it,
 
"Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" 
   

Answers (1)