locked
how to check database connectivity in enterprise library 4.1? RRS feed

  • Question

  • User430178104 posted

    how to check database connectivity in enterprise library 4.1? 

    Wednesday, February 10, 2010 1:38 AM

All replies

  • User-37275327 posted

     Is it availability of database or activedata connection? Can you explain in detail?

    Wednesday, February 10, 2010 12:04 PM
  • User1247222288 posted

    how we can check both? 

    Tuesday, February 16, 2010 3:58 AM
  • User-37275327 posted

    Hi Viya1243,

    Sorry for the delayed answere. Hope this will help.


    Private Sub SaveRecord()

            Dim _Connection As DbConnection = Nothing
            Dim _Transaction As DbTransaction = Nothing

            Try

                Dim _DB As Database = DatabaseFactory.CreateDatabase("PPConnectionString")

                _Connection = _DB.CreateConnection
                _Connection.Open()
                _Transaction = _Connection.BeginTransaction()

          
           //Do something here, adding required parameters
          

                _Transaction.Commit()


            Catch ex As Exception
                _Transaction.Rollback()

            Finally
                If _Connection.State = ConnectionState.Open Then
                    _Connection.Close()
                End If

            End Try
    End Sub

    Note the _Connection.State section, you can check status of the connection.

    Wednesday, February 24, 2010 9:18 AM