Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

unable to read data from the transport connection an existing connection was forcibly closed by the remote host in postgresql !

postgres connection

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 viveq

viveq

    CC Regular

  • Member
  • PipPipPip
  • 46 posts

Posted 22 August 2013 - 10:20 PM

plz help.....

 

this is my connection method to postgresDB

 

 Public Function GenConnection() As NpgsqlConnection
        Dim Connection As New NpgsqlConnection("Server=" & gstrServerName & ";Port=" & gstrPort & ";Database=" & gStrDBName & ";Pooling=false;MINPOOLSIZE=0;CONNECTIONLIFETIME=0;COMMANDTIMEOUT=0;MAXPOOLSIZE=100;Username=" & gstrUserName & ";Password=" & gPassword)
        Try
            If Connection.State = ConnectionState.Open Then
                Connection.Close()
            End If
            Connection.ClearAllPools()
            Connection.Open()
            gblnValidConnection = True
            Return Connection
        Catch ex As Exception
            gblnValidConnection = False
            MsgBox(ex.Message)
        End Try
    End Function

 

and the above mentioned problem occuring unexpectdly in datareader and datatable ....

 

 Public Function GetDataTable(ByVal cmdText As String) As DataTable
        Dim dt As New DataTable
        Dim command As New NpgsqlCommand(cmdText, GenConnection)
        Dim dataAdapter As New NpgsqlDataAdapter(command)
        Try
            dataAdapter.Fill(dt)
            GenConnection.Close()
            GenConnection.ClearAllPools()
            Return dt
        Catch exc As NpgsqlException
            MessageBox.Show(exc.ToString())
            ThrowNpgsqlException(exc)
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
            ErrorLogging(DateAndTime.Now)
            ErrorLogging(ex.ToString)
            Dim errObj As New FrmError
            errObj.GenErr.DisplayError(ex.Message, ex.ToString)
            errObj.ShowDialog()
        End Try
    End Function

 

 

 

and

 

 

 

Public Function GetDataReader(ByVal cmdText As String) As NpgsqlDataReader
        Dim dr As NpgsqlDataReader

        Dim command As New NpgsqlCommand(cmdText, GenConnection)
        Try
            dr = command.ExecuteReader
            Return dr
        Catch exc As NpgsqlException
            ThrowNpgsqlException(exc)
        Catch ex As Exception
            ErrorLogging(DateAndTime.Now)
            ErrorLogging(ex.ToString)
            Dim errObj As New FrmError
            errObj.GenErr.DisplayError(ex.Message, ex.ToString)
            errObj.ShowDialog()
        End Try
    End Function

 

 

 

 

 

 

 

 

 

 



i got this from pg_log

 

2013-08-23 11:43:03 IST LOG:  setsockopt(TCP_KEEPCNT) not supported

 

2013-08-23 11:31:45 IST LOG:  could not receive data from client: No connection could be made because the target machine actively refused it.


Edited by viveq, 22 August 2013 - 10:15 PM.

:thumbup1:  ..::To Finish First You Have To Start First::.. :thumbup1:





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download