Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private ds As DataSet
Private dv As DataView
Private ConStr As String = "Data Source= .\SQLEXPRESS;Initial Catalog = C:\ADVENTUREWORKS_DATA.mdf;Integrated Security=True;User Instance=True;"
Private cn As SqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New SqlConnection(ConStr)
ds = New DataSet
dv = New DataView
Dim ad As New SqlDataAdapter("SELECT * FROM Production.Product", cn)
ad.Fill(ds, "Production")
dv.Table = ds.Tables("Production")
Me.DataGridView1.DataSource = dv
End Sub
Private Sub filterSortDemo()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim strVal As String
strVal = Me.ComboBox1.Text
Label3.Text = "The data is sorted on column " & strVal
dv.Sort = strVal
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class