Imports System.Data.SqlClient

Public Class BoundForm

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Connect As String = "Data Source=localhost;Integrated Security=True;" & _
          "Initial Catalog=Northwind;"
        Dim con As New SqlConnection(Connect)

        Dim SQL As String = "SELECT * FROM Employees"
        Dim cmd As New SqlCommand(SQL, con)

        Dim adapter As New SqlDataAdapter(cmd)
        Dim dsNorthwind As New DataSet()

        con.Open()

        adapter.Fill(dsNorthwind, "Employees")

        con.Close()

        ' Dodawanie wiązań.
        gridDB.DataSource = dsNorthwind.Tables("Employees")

        txtFirstName.DataBindings.Add("Text", dsNorthwind.Tables("Employees"), "FirstName")
        txtLastName.DataBindings.Add("Text", dsNorthwind.Tables("Employees"), "LastName")

        lstID.DataSource = dsNorthwind.Tables("Employees")
        lstID.DisplayMember = "EmployeeID"

        dtBirth.DataBindings.Add("Value", dsNorthwind.Tables("Employees"), "BirthDate")


    End Sub

End Class