I am creating an application in WPF
which inserts in a table of SQLite
every login.
When you are about to insert: throw this exception:
The code of the method to insert is this:
public void InsertValuesToDataBase (string user, string pass)
{
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "DB.sqlite"))
{
SQLiteConnection conectionInsert = new SQLiteConnection("Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "DB.sqlite;" + "Version=3;");
string consulta = "INSERT INTO User (user, pass) values(@param1,@param2)";
SQLiteCommand Insert = new SQLiteCommand(consulta, conectionInsert);
Insert.Parameters.AddWithValue("@param1", user);
Insert.Parameters.AddWithValue("@param2", pass);
conectionInsert.Open();
Insert.ExecuteNonQuery();
conectionInsert.Close();
}
else
{
//alter here
}
}
And I call him from another class in this way:
sim_sql_lite = new SIMSQLite();
sim_sql_lite.InsertValuesToDataBase("abc", "123");
The location of the SQLite
file is in the same directory where Visual Studio
creates the compiled .exe
of the program.
C:\...\bin\Debug
Any suggestions?