Dim cn As New SqlConnection(Form1.ConString)
If cn.State = ConnectionState.Open Then cn.Close()
Dim sql As String = "SELECT * From [Course] WHERE [StartDate] < @SystemDate"
Dim cm As New SqlCommand(sql, cn)
cm.Parameters.AddWithValue("@SystemDate", DateTime.Today)
Try
Dim dataSource As New DataTable()
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = cm
adapter.Fill(dataSource)
DataGridView1.DataSource = dataSource
Catch ex As Exception
MsgBox("เกิดข้อผิดพลาดจากสาเหตุ: " & ex.Message)
End Try