hi friends i m doing project in vb and database is microsoft access
in my form i have 3 radiobuttons and 3 combobox when i select radio button then respective combobox enable and remainig disable i load all the data in combobox through data reader the problem is user can select different radio button so as query also changes to fetch the data from databse whenever i select 1 rasio buttons its work whenever select it not work pl help
Do While dr.Read
ComboBox1.Items.Add(dr(0).ToString)
ComboBox2.Items.Add(dr(7).ToString)
ComboBox3.Items.Add(dr(1).ToString)
Dim danew As OleDbDataAdapter
Dim dsnew As DataSet
Dim query As String = ""
Dim name As String
Dim id As String
Dim room As Integer
id = ComboBox1.SelectedItem
room = ComboBox2.SelectedItem
name = ComboBox3.SelectedItem
Dim cmdbobj As OleDbCommand
If ComboBox1.SelectedItem Then
query = "select * from Member where Id=" & id
ElseIf ComboBox2.SelectedItem Then
query = "select * from Member where RoomNo='" & room & "'"
Else
query = "select * from Member where MemberName='" & name & "'"
End If
danew = New OleDbDataAdapter(query, con)
dsnew = New DataSet
con.Open()
Try
cmdbobj = New OleDbCommand(query, con)
danew.Fill(dsnew, "Member")
DataGridView1.DataSource = dsnew
DataGridView1.DataMember = "Member"
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
con.Close()