VB.NET receives no response from PostgreSQL 9.3 when inserting duplicate record

1

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?

    
asked by Xavier Crespo 28.02.2017 в 09:23
source

1 answer

1

According to this thread , your problem is definitely a flaw in the version of Npsql that you use (2.0.12.0).

Translating a part of the reference:

  

We just realized that Npgsql has a problem handling error messages from PostgreSQL 9.3.x [...] We are working on producing a stable version 2.0.12 with the correction.

In your case, since version 2.x is already a bit old, I suggest you put your Npsql up to date with a of the latest available versions and that should fix your problem.

    
answered by 28.02.2017 / 15:29
source