Question radio button checked and not checked at same time

Deepakgates

New member
Joined
May 5, 2010
Messages
3
Programming Experience
Beginner
okay then ....
im making dynamic sql statement
rmode is a radio button and tmode is a combo box



VB.NET:
Private Sub bsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bsearch.Click

        If rmode.Checked = True Then

        ElseIf tmode.SelectedIndex = 0 Then
            sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
        ElseIf tmode.SelectedIndex = 1 Then
            sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
        End If

        

          If rmode.Checked = True Then
            MsgBox("mode")

        End If






        con.Open()
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "licdb")
        con.Close()
        datagridresult.DataSource = ds.Tables("licdb").DefaultView
    End Sub


im facing a hell of a problem
do u see two if statement
just one get executed

the second one... if i put only second then it gets executed and if only first then nothing gets executed..

WHYYYYYYYYYYYYYYYY????

PS: radiobutton is checked!!
 
im making dynamic sql statement
First off, BRAVO...I'm glad to see SQL is still alive and well.

Second, I'm not sure what you are attempting to accomplish.
VB.NET:
ElseIf tmode.SelectedIndex = 0 Then
            sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
        ElseIf tmode.SelectedIndex = 1 Then
            sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
        End If
You are executing the exact same SELECT query regardless of what is true. So, the question is what difference does it make what is selected? The results would be the same.
 
Back
Top