Results 1 to 2 of 2

Thread: simple vb error

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    Westfield, IN, USA
    Posts
    59

    simple vb error

    I have a small portion of code that trips up my script every time i run it. I get the error message "Input string was not in a correct format". The offending code is:

    Code:
    Dim sScriptName as string = Request.ServerVariables("SCRIPT_NAME").ToLower()
    Dim iLastSlash as integer = sScriptName.LastIndexOf("/")
    sScriptName = sScriptName.Substring(iLastSlash + 1)
    If (sScriptName.ToString() = Not "default.aspx") And (sScriptName.ToString() = Not "users.aspx") Then
    	If Session("Admin") = "" Then
    		Response.Redirect("Default.aspx")
    	End If
    End If
    I also get it when running:
    Code:
    If Session("Admin") = Not DBNull.Value.ToString() Then
    ...
    End If
    Any ideas?

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I am not sure what you are trying to do, but try this, it seems like it is what you want:
    Code:
    If (sScriptName <> "default.aspx") And (sScriptName <> "users.aspx") Then
    	If Session("Admin") = "" Then
    		Response.Redirect("Default.aspx")
    	End If
    End If
    
    
    If Session("Admin") <> DBNull.Value.ToString() Then
    ...
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width