kavithabhaskar 0 Junior Poster

my selection of one, or 2 or all 3 at a time should get connected to a SQL query and get executed but that does not happen here atall.can u all please take a look at this code and help me with this..

please..'

thanks

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

Dim con As 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) Then

cmd1 = New OleDbCommand("select * from table1 where MECH='X'")

Else
If (CheckBox2.Checked = True) Then

cmd1 = New OleDbCommand("select * from table1 where MACH='X'")

ElseIf (CheckBox3.Checked = True) Then

cmd1 = New OleDbCommand("select * from table1 where UGSTRUCTURES='X'")


End If

Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd1)

Try
Dim ds As DataSet = New DataSet()

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

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.