dimanche 6 septembre 2015

System.Data.Sqlite throw no excepion in .NET 4 c#

I have a unusual problem: the library System.Data.SqLite throw absolutely no exception! It's the first time i use this type of database in c# ( usually i used a centralized db or single file...) and its possible i have done something wrong. I instance a single persistant connection for the whole program:

public static SQLiteConnection m_dbConnection;

In the init method i open it:

m_dbConnection = new SQLiteConnection(string.Format("Data Source={0};Version=3;", dbLoc));

m_dbConnection.DefaultTimeout = 2;
m_dbConnection.Open();

And then I use it around the programs like this:

string sql = string.Format("insert into Scadenze (Data, Annotazioni, Descrizione,NumeroRG,NumeroPratica, Color) VALUES (@Data,@Annotazioni, @Descrizione, @NumeroRG, @NumeroPratica, @Color);");

...

SQLiteCommand command = new SQLiteCommand(sql, DB.m_dbConnection);
command.CommandTimeout = 2;
command.Parameters.Add(new SQLiteParameter("@ID", this.ID));
....
command.ExecuteNonQuery();

In every case (ExecuteNonQuery/ExecuteScalar/ExecuteReader) i get NO exception if something go wrong and the application simply do nothing ( no freeze... it simply wait the end of the operation forever...)

Anyone know if this has something to do with how i use the lib? Thanks!

Aucun commentaire:

Enregistrer un commentaire