Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strSQL As String
Dim mycommand As SqlCommand
Dim dr As SqlDataReader
Dim dt As DataTable
If CheckBox1.CheckState = CheckState.Checked Then
strSQL = "SELECT ..."
End If
If CheckBox2.CheckState = CheckState.Checked Then
strSQL = "SELECT ..."
End If
mycommand = New SqlCommand(strSQL)
dr = mycommand.ExecuteReader
If dr.HasRows Then
dt = New DataTable
dt.Load(dr)
DataGridView1.DataSource = dt
Else
DataGridView1.DataSource = Nothing
End If
End Sub