Reputation: 79
New to wpf and sqlite. I just want an internal database for my project. I want this project to be able to used by others so I cannot use mysql as a database. So I search for internal databases and decided to try sqlite. Im finding tutorial but they are really confusing. I'm familiar in database I know the queries but now I just need to know what are the necessary things to setup to start the connection between WPF and sqlite. Below is my code(I create a different class for my sqlite connection):
sqlite class
using System.Data.SQLite;
namespace StartMyApps
{
class StartMyAppDb_sqlite
{
public SQLiteConnection myConn;
public SQLiteCommand myComm;
public SQLiteDataReader myReader;
public void openConnection(string query)
{
myConn = new SQLiteConnection("Data Source=StartMyApplication.sqlite;Version=3;");
myConn.Open();
myComm = new SQLiteCommand(query, myConn);
myComm.ExecuteNonQuery();
myReader = myComm.ExecuteReader();
}
}
}
Main class (has a button to trigger the connection and will pass a query)
private void hide_btn_Click(object sender, RoutedEventArgs e)
{
sqliteDB.openConnection("select *from application where app_id='1' and app_name='chrome.exe';");
bool hasAccount = false;
while (sqliteDB.myReader.Read())
{
hasAccount = true;
}
if (hasAccount == false)
{
MessageBox.Show("Logged in");
}
else if (hasAccount == true)
{
MessageBox.Show("Username invalid");
}
}
With this code I got an error says
"An unhandled exception of type 'System.DllNotFoundException' occurred in System.Data.SQLite.dll Additional information: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
Please help. Any help will be much appreciated THANKS!
Upvotes: 1
Views: 2159
Reputation: 781
I think this is what your looking for: Unable to load DLL 'SQLite.Interop.dll'
Assuming you have:
SQLite installed (correct version for windows)
Appropriate references
Upvotes: 1
Reputation: 76
Follow below steps:
Upvotes: 0