I have a question.. my form I have 4 checkboxes and I have a click button..the idea is when any one or 2 or 3 or all 4 checkboxes are checked, a SQL statement should be executed and the results should be displayed in a datagridview.

now..i have been writing the code for the checkedstate=true/false in the button_clicked I have to write any code inside the checkbox1_checkedchanged and similarly for the other check boxes?

Please let me know..



my code is as follows

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim con As OleDbConnection = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")

Dim cmd1 As New OleDbCommand


If (CheckBox1.Checked = True) And (CheckBox1.Checked = True) And (CheckBox3.Checked = True) And (CheckBox4.Checked = True) Then

cmd1 = New OleDbCommand("select * from table1 where MECH='X' and MACH='X' AND UGSTRUCTURES='X' AND UGPCBXCHANGE='X'")

Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd1)

Dim ds As DataSet = New DataSet()


da.Fill(ds, "table1")

DataGridView1.DataSource = ds.Tables("table1").DefaultView



cmd1 = Nothing



End Try

End If

End Sub

End class

hiii.... why have u written
checkbox1.checked=true twice...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.