If Then Else Statement Condition Being Ignored?
- by Matma
I think im going mad but can some show me what im missing, it must be some stupidly simple i just cant see the wood for the trees.
BOTH side of this if then else statement are being executed?
Ive tried commenting out the true side and moving the condition to a seperate variable with the same result. However if i explicitly set the condition to 1=0 or 1=1 then the if then statement is operating as i would expect. i.e. only executing one side of the equation...
The only time ive seen this sort of thing is when the compiler has crashed and is no longer compiling (without visible indication that its not) but ive restarted studio with the same results, ive cleaned the solution, built and rebuilt with no change?
please show me the stupid mistake im making
using vs2005 if it matters.
Dim dset As DataSet = New DataSet
If (CboCustomers.SelectedValue IsNot Nothing) AndAlso (CboCustomers.SelectedValue <> "") Then
Dim Sql As String = "Select sal.SalesOrderNo As SalesOrder,cus.CustomerName,has.SerialNo, convert(varchar,sal.Dateofpurchase,103) as Date from [dbo].[Customer_Table] as cus " & _
" inner join [dbo].[Hasp_table] as has on has.CustomerID=cus.CustomerTag " & _
" inner join [dbo].[salesorder_table] as sal On sal.Hasp_ID =has.Hasp_ID Where cus.CustomerTag = '" & CboCustomers.SelectedValue.ToString & "'"
Dim dap As SqlDataAdapter = New SqlDataAdapter(Sql, FormConnection)
dap.Fill(dset, "dbo.Customer_Table")
DGCustomer.DataSource = dset.Tables("dbo.Customer_Table")
Else
Dim erm As String = "wtf"
End If