Public Sub ReadMyData(ByVal myConnString As String)
Dim pgConnection As New PgSqlConnection(myConnString)
Dim pgCommand As PgSqlCommand = pgConnection.CreateCommand()
pgCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Test.Dept"
pgConnection.Open()
Dim pgReader As PgSqlDataReader = pgCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While pgReader.Read()
Console.WriteLine(String.Concat(pgReader.GetInt32(0).ToString(), " ", _
pgReader.GetString(1), " ", pgReader.GetString(2)))
End While
Finally
' always call Close when done reading.
pgReader.Close()
' Close the connection when done with it.
pgConnection.Close()
End Try
End Sub