Friends:

I have a question.. now..in 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 code..do I have to write any code inside the checkbox1_checkedchanged and similarly for the other check boxes?

Please let me know..

thanks

kavitha.

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

con.Open()

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)

Try
Dim ds As DataSet = New DataSet()

ds.Tables.Add("table1")

da.Fill(ds, "table1")

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

Finally

con.Close()

cmd1 = Nothing

da.Dispose()

con.Dispose()


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, networking, learning, and sharing knowledge.