This is the code that I wrote for database connection:
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
using (SQLiteConnection con = new SQLiteConnection(connectionString))
{
try
{
con.Open();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
if (con.State == System.Data.ConnectionState.Open)
{
Console.WriteLine("Database Opened");
ushort[] writeData = new ushort[10];
writeData = parseList(byteList);
if (writeData != errorBytes)
{
writeToDb(con, writeData);
}
else
{
Console.WriteLine("Error Bytes returned! BROKEN DATA!!!");
}
//con.Close();
}
else
{
Console.WriteLine("Can't open the database!");
}
}
}`
When I run the program on the computer that I wrote the code it works properly and opens the database. However when I run my program in another computer code doesn't go into using
statement and gives the exception SQLite.Interop.dll
not found. I added the System.Data.SQLite.dll
to my project's references. Also I have this dll file in the other computer. Do I need to add anything to the other computer to make this program work properly?
I figured it out that the problem was about SQLite dlls. When I installed the System.Data.SQLite library from NuGet Package Manager and set the platform target as x86 problem resolved. Although platform target was x86 before I asked this question but re-installing the library from NuGet Package Manager solved my problem. Before that I was using the dlls I downloaded from the http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki as reference to my project.