Dim conn As New SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet()
Dim strconn As String
strconn = "Data Source=.;Initial Catalog=dbTEST2;Integrated Security=True"
If conn.State = ConnectionState.Open Then
conn.Close()
Else
conn.ConnectionString = strconn
conn.Close()
End If
Dim strSQL As String
If CheckBox123.Checked = True Then
strSQL = "SELECT realname,subname,address,phone,Office FROM history"
ElseIf CheckBox1.Checked = True Then
strSQL = "SELECT realname,subname FROM history"
ElseIf CheckBox2.Checked = True Then
strSQL = "SELECT address,phone FROM history"
ElseIf CheckBox3.Checked = True Then
strSQL = "SELECT Office FROM history"
End If
da = New SqlDataAdapter(strSQL, conn)
ds.Tables.Clear()
da.Fill(ds, "history")
dgvSQL.DataSource = ds.Tables("history")