The exception that is generated when SQLite returns an error.
The following example generates a
SQLiteException due to a non-existing table, and then displays the exception.
|
|---|
public void ThrowSQLiteException()
{
string mySelectQuery = "SELECT * FROM NONEXISTINGTABLE";
SQLiteConnection sqLiteConnection =
new SQLiteConnection(
"DataSource=mydatabase.db;");
SQLiteCommand sqLiteCommand = new SQLiteCommand(mySelectQuery,sqLiteConnection);
try
{
sqLiteCommand.Connection.Open();
}
catch (SQLiteException myException)
{
MessageBox.Show("Message: " + myException.Message + "\n");
}
} |
|
|---|
Public Sub ThrowSQLiteException()
Dim mySelectQuery As String = "SELECT * FROM NONEXISTINGTABLE"
Dim sqLiteConnection As New SQLiteConnection( _
"DataSource=mydatabase.db;")
Dim sqLiteCommand As New SQLiteCommand(mySelectQuery, sqLiteConnection)
Try
sqLiteCommand.Connection.Open()
Catch myException As SQLiteException
MessageBox.Show("Message: " + myException.Message + ControlChars.Cr)
End Try
End Sub |