Following C# code runing in .NET 2 causes error in Update() line
Npgsql.NpgsqlException was unhandled by user code
Why exception is not catched ?
catch must catch ALL exceptions.
int RowsUpdated;
try {
RowsUpdated = datapter.Update(changes);
}
catch {
System.Windows.Forms.MessageBox.Show("error");
transact.Rollback();
throw;
}
error message details are:
Npgsql.NpgsqlException was unhandled by user code
Message="ERROR: 23505: duplicate key violates unique constraint \"konto_pkey\""
Source="Npgsql"
BaseMessage="duplicate key violates unique constraint \"konto_pkey\""
Code="23505"
Detail=""
ErrorSql="update \"firma1\".\"konto\" set \"kontonr\" = '2', ....
File="nbtinsert.c"
Hint=""
Line="277"
Position=""
Routine="_bt_check_unique"
Severity="ERROR"
Where=""
StackTrace:
at Npgsql.NpgsqlConnector.CheckErrors() in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlConnector.cs:line 359
at Npgsql.NpgsqlConnector.CheckErrorsAndNotifications() in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlConnector.cs:line 410
at Npgsql.NpgsqlCommand.ExecuteCommand() in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlCommand.cs:line 1479
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior cb) in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlCommand.cs:line 633
at Npgsql.NpgsqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior cb) in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlCommand.cs:line 601
at System.Data.Common.DbDataAdapter.UpdateRowExecute(RowUpdatedEventArgs rowUpdatedEvent, IDbCommand dataCommand, StatementType cmdIndex)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
Andrus