I have migrated from PostgreSQL 8.3 to PostgreSQL 9.3 to be able to use the improvements implemented in this version. With version 8.2 I had no problem controlling errors when trying to insert a duplicate record with a unique key since the program (Visual Studio 2013 vb.net) received PostgreSQL message and acted accordingly with a TRY...CATCH
clause. But since I have migrated to 9.3, when making insert
, the program is waiting to receive a message from PostgreSQL 9.3 and does not continue. I attached an example code:
Public Sub EjecutaComando(ByVal StringSql As String)
'Procedure básico para ejecutar Insert i Updates sin tenerlas que implementar en cada uno de los procesos
Dim data As New NpgsqlCommand
data.Connection = MiConexio
data.CommandText = StringSql
Try
AbrirConexion()
data.ExecuteNonQuery()
Catch ex As Exception
nada()
Finally
CerrarConexion()
data.Dispose()
End Try
End Sub
If the statement is a insert
against a table with a unique key, the code stops at data.ExecuteNonQuery()
. I run the query from PgAdmin and it returns an error message of duplicate Key
. The Npgsql version I use is 2.012.0
.
Can someone illuminate me where the problem is?