If Else Statement

Discussion in 'C#' started by vb89, Sep 24, 2008.

  1. #1
    (This is a classic asp page pulling data from an oracle database) I basically just want the first if statement to overwrite the second statement in the case that the criteria of the first if statement is met. So basically if the league_id value is 0 and the team id value is 0 I would like the tSQL function to display main.cfb_division_id = 1" and - Division: I-A"...any help on how to edit my code to do that would be great...thanks


    
            If iLeagueID = "0" and iTeamID = "0" then
        	tSQL = tSQL & " AND main.cfb_division_id = 1"
    		tPlayerFilter = tPlayerFilter & " - Division: I-A"
            End If 
     
    	    If iLeagueID = "0"  Then
    	    tSQL = tSQL
            tPlayerFilter = tPlayerFilter 
    		ElseIf iLeagueID = "2" Then
         	tSQL = tSQL & " AND main.cfb_division_id = 2"
    	 	tPlayerFilter = tPlayerFilter & " - Division: I-AA"
    		ElseIf iLeagueID = "9" Then
    		tSQL = tSQL & " AND main.cfb_division_id = 9"
    		tPlayerFilter = tPlayerFilter & " - Division: I-A + I-AA"
         	ElseIf iLeagueID = "1" Then
        	tSQL = tSQL & " AND main.cfb_division_id = 1"
    		tPlayerFilter = tPlayerFilter & " - Division: I-A"
    		End If
    
    Code (markup):
     
    vb89, Sep 24, 2008 IP
  2. mintoj

    mintoj Peon

    Messages:
    317
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:


    
            If iLeagueID = "0" and iTeamID = "0" then
        	tSQL = tSQL & " AND main.cfb_division_id = 1"
    		tPlayerFilter = tPlayerFilter & " - Division: I-A"
            Else
                 If iLeagueID = "2" Then
         	      tSQL = tSQL & " AND main.cfb_division_id = 2"
    	      tPlayerFilter = tPlayerFilter & " - Division: I-AA"
    	       ElseIf iLeagueID = "9" Then
    	       tSQL = tSQL & " AND main.cfb_division_id = 9"
    	       tPlayerFilter = tPlayerFilter & " - Division: I-A + I-AA"
                         ElseIf iLeagueID = "1" Then
        	       tSQL = tSQL & " AND main.cfb_division_id = 1"
    	       tPlayerFilter = tPlayerFilter & " - Division: I-A"
                 End If
          End If
    
    Code (markup):
     
    mintoj, Sep 25, 2008 IP