Connection to IBM Db2 : Db2 « Database ADO.net « VB.Net






Connection to IBM Db2

Imports System
Imports System.Data
Imports IBM.Data.DB2

public class MainClass
   Shared Sub Main()
      Dim connString As String = "database = databaseName;"

      Dim conn As New DB2Connection(connString)

      Try
         conn.Open()
         Console.WriteLine("Connection Opened")

         Console.WriteLine("Connection Properties")
         Console.WriteLine("- ConnectionString : {0}",conn.ConnectionString)
         Console.WriteLine("- Database : {0}", conn.Database)
         Console.WriteLine("- ServerVersion : {0}",conn.ServerVersion)
         Console.WriteLine("- State : {0}", conn.State)

      Catch ex As DB2Exception
         Console.WriteLine("Error: " & ex.ToString())
      Finally
         conn.Close()
         Console.WriteLine("Connection Closed")

      End Try
   End Sub
End Class

           
       








Related examples in the same category