Imports System.Data.SqlClient

Public Class Grid

    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 Products"
        Dim cmd As New SqlCommand(SQL, con)

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

        con.Open()

        adapter.Fill(dsNorthwind, "Products")

        '' To polecenie jest wciąż powiązane z adapterem danych.
        'cmd.CommandText = "SELECT * FROM Customers"
        'adapter.Fill(dsNorthwind, "Customers")

        'cmd.CommandText = "SELECT * FROM Employees"
        'adapter.Fill(dsNorthwind, "Employees")

        con.Close()

        gridDB.DataSource = dsNorthwind.Tables("Products")
    End Sub
End Class