Timeout for Oracleconnection

Asked

Viewed 198 times

0

I have a function to open the connection of the banks in Oracle and in this function I want to put a time limit to the attempt to connect to the bank.

I tried to use ConnectionString in this way

oConexao.ConnectionString = "Data Source = MeuBd; User Id = MeuID; Password = 88997k21; Connection Timeout = 10;"

But it didn’t work, falling into an exception and accusing that there is no support for the keyword: 'connectiontimeout'.

Function:

Private Shared Function AbrirConexaoOracle(ByVal sNomeBanco As String, Optional ByRef mensagem As String = "") As OracleClient.OracleConnection

        Dim oConexao As OracleClient.OracleConnection

        Try
            oConexao = New OracleClient.OracleConnection
            If sNomeBanco = "OUTROS" Then
                oConexao.ConnectionString = mensagem
                mensagem = String.Empty
            Else
                oConexao.ConnectionString = LerConnectionString(sNomeBanco) 'MontarConnectionString(sNomeBanco)
            End If                
            oConexao.Open()
        Catch ex As Exception
            mensagem = ex.Message.ToString
            If Not oConexao Is Nothing Then
                oConexao.Close()
                oConexao.Dispose()
            End If
        End Try
        Return oConexao

    End Function

How can I give this limit to the attempt at connection in the case of the use of OracleConnection ?

  • Using Connection Timeout=XX; in your ConnectionString should work! Can you put the error you are receiving? (the original error and not a translation and/or description of it)

  • The message is that same, There is support for the keyword: 'Connection timeout'. As soon as it falls on the line oConexao.ConnectionString = "Data Source = MeuBd; User Id = MeuID; Password = 88997k21; Connection Timeout = 10;" goes straight to Exception and returns the error.

  • Which data provider you are using (SQL Server, OLE DB, ODBC, other...) ?

  • I use OLE DB.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.