Question : what was checked

I am using VB.Net and I have a page that has 2 text boxes and 4 check boxes.

The first text box is for the salesman ID and the check boxes are for the different types of orders.
Bid, Regular, Backorder and returns.
the second text box is used to store the info about which box was checked.

I want to pass which box via session var to a sql query. My problem is the formating of the sql query depending on which box(s) are checked.

Here is what I am trying, but if will not work based on my query. And I am not sure how to change this so it will work.

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        Session("SalesmanID") = TextBox1.Text.ToUpper
        If cbBids.Checked Then
            TextBox2.Text = "sotype = 'B'"
        End If

        If cbReturns.Checked Then
            TextBox2.Text = TextBox2.Text & " Or sotype = 'R'"
        End If

        If cbPartial.Checked Then
            TextBox2.Text = TextBox2.Text & " Or sotype = 'O'"
        End If

        If cbRegular.Checked Then
            TextBox2.Text = TextBox2.Text & " Or sotype = ''"
        End If

        Session("what") = TextBox2.Text
        MsgBox(TextBox2.Text)

        Response.Redirect("SOS.aspx")

    End Sub


Here is my query
SELECT sono, sodate, ordate, custno, shpamt, ponum, sotype, ordamt, salesmn FROM somast WHERE (salesmn = @SalesmanID) AND (sostat <> 'C') AND (sostat <> 'V') AND (sotype = @what) ORDER BY sotype

Answer : what was checked

Try this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        Session("SalesmanID") = TextBox1.Text.ToUpper
        TextBox2.Text = ""
        If cbBids.Checked Then
            TextBox2.Text = "sotype = 'B'"
        End If

        If cbReturns.Checked Then
            If TextBox2.Text = "" Then
                TextBox2.Text = "sotype = 'R'"
            Else
                TextBox2.Text = TextBox2.Text & " Or sotype = 'R'"
            End If
        End If

        If cbPartial.Checked Then
            If TextBox2.Text = "" Then
                TextBox2.Text = "sotype = 'O'"
            Else
                TextBox2.Text = TextBox2.Text & " Or sotype = 'O'"
            End If
        End If

        If cbRegular.Checked Then
            If TextBox2.Text = "" Then
                TextBox2.Text = "sotype = ''"
            Else
                TextBox2.Text = TextBox2.Text & " Or sotype = ''"
            End If
        End If

        Session("what") = TextBox2.Text
        MsgBox(TextBox2.Text)

        Response.Redirect("SOS.aspx")

    End Sub
Random Solutions  
 
programming4us programming4us