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
|