SqlConnection.Database : SqlConnection « System.Data.SqlClient « VB.Net by API






SqlConnection.Database

  

Imports System
Imports System.Data
Imports System.Data.SqlClient

public class MainClass
   Shared Sub Main()
      Dim connString As String = "server=(local)\SQLEXPRESS; " & _
         "integrated security=sspi;"

      Dim conn As New SqlConnection(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("- DataSource : {0}", conn.DataSource)
         Console.WriteLine("- ServerVersion : {0}", conn.ServerVersion)
         Console.WriteLine("- State : {0}", conn.State)
         Console.WriteLine("- WorkstationId : {0}", conn.WorkstationId)

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

      End Try
   End Sub
End Class

   
    
  








Related examples in the same category

1.SqlConnection.DataSource
2.SqlConnection.InfoMessage
3.SqlConnection.ServerVersion
4.SqlConnection.StateChange
5.SqlConnection.Version
6.SqlConnection.WorkstationId