Tuesday, 15 January 2013

how does one get csharp-sqlite to throw exceptions for duplicates or foreign key constraint violations -


I am currently using csharp-sqlite in SQLite database, I have some uniqueness and foreign key constraints but when I I write "duplicate" in a table, the exception is not raised and the only way I can check the exception is to do something like this:

  var error = sqlite com getLastError ();  

I was hoping to be able to do the following:

  var sqlstring = "adding something to SQL"; Var command = squat command (sqlstring); Command. Parameter. Add (... some parameters ...); {Try.ExecuteNonQuery (try) using (var sqlConnection = new SqliteConnection (connectionString)); } Hold (exception before) {do something with exception} {sqlConnection.Close (); }}  

The "catch" block is never killed, even if

  var error = sqliteCommand.GetLastError ();  

Returns with a description of the error that I expected to have someone have an idea of ​​how to solve it, or standard practice is using the csharp-sqlite library ?


No comments:

Post a Comment