0

I'm trying to force an error condition to test some exception handling by updating a row after it has been deleted using the following steps:

1. Load record into GUI
2. Pull .db3 file to Windows
3. Delete record with sqlite3
4. Push .db3 file back to Android
3. Save record from GUI

However, there is no exception thrown from ExecuteNonQuery() nor is there anything in logcat.

Why, if for Step 3, the DB file is instead renamed an exception thrown, but not when deleting the record?


Update: Deleting the record directly from the device with sqlite3 results in this same behavior.

Note: Samsung Galaxy Tab2 requires the PIE (Position Independent Execution) version.

samus
  • 6,102
  • 6
  • 31
  • 69
  • 2
    It may be reading/writing from the journal file. Instead of steps 2-4, write some extra code to delete the record and attempt the save. See https://stackoverflow.com/questions/26209091/what-is-the-journal-sqlite-database-in-android for good reading! – petey Jul 06 '17 at 18:47

3 Answers3

1

Updating a row doesn't throw any error/exception in sql. when a row is not found in database update query does nothing and show no error/exception message.

yash darak
  • 368
  • 4
  • 17
  • I'll test this out. I prefer not adding code to break stuff when testing, since it requires changing it. I prefer introducing as *"real-world"* scenarios as possible, but for this I'll give **petey**'s suggesting a try (renaming the DB file gave an exception sufficient for testing the associated try/catch, so I didn't proceed further but am now interested in observing this behavior). – samus Jul 10 '17 at 12:56
1

The update query does not throw any errors.

Simon H
  • 2,495
  • 4
  • 30
  • 38
0

I am not entirely sure about the sql3 data provider. However, you would want to use a query function, not a non query for the delete. Get the rows affected by deletion in the query. And then throw and exception ad required for the scenario when no rows are returned.

Aamir Mulla
  • 76
  • 1
  • 6
  • `ExecuteNonQuery()` is called from the `Mono.Data.Sqlite` provider after a `delete` statement is ran from the `sqlite3` command line interface. – samus Jul 07 '17 at 12:46