I am currently making use of csharp-sqlite. In the SQLite database I have some uniqueness and foreign key constraints. But when I write a "duplicate" to a table an exception is not raised and the only way I found to check for an exception is to use something like the following:
var error = sqliteCommand.GetLastError();
I was hoping to be able to do the following:
var sqlstring = "some insert sql";
var command = SqliteCommand(sqlstring);
command.Parameters.Add(... some parameter...);
using (var sqlConnection = new SqliteConnection(connectionString))
{
try
{
command.ExecuteNonQuery();
}
catch (Exception ex)
{
do something with the exception
}
finally
{
sqlConnection.Close();
}
}
The "catch" block is never hit, even though the
var error = sqliteCommand.GetLastError();
does return with a description of the error that I was expecting. Does anyone have an idea how to solve this, or what standard practice is using the csharp-sqlite library?
Aucun commentaire:
Enregistrer un commentaire