[Mono-list] Why npgsql exception is not catched ?

Andrus kobruleht2 at hot.ee
Sun Dec 24 13:04:24 EST 2006


The following code causes error in Update() line

Npgsql.NpgsqlException was unhandled by user code

Why exception is not catched ?
catch must catch AL EXCEPTIONS!

------ code:

   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. 



More information about the Mono-list mailing list