Exception occured error

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Exception occured error

    I'm getting an Exception occured error on line 4 (For i =1...)

    <% Function ProperCase(strIn)
    strOut = ""
    boolUp = True
    For i = 1 To Len(strIn)
    c = Mid(strIn, i, 1)
    if c = " " or c = "'" or c = "-" then
    strOut = strOut & c
    boolUp = True
    Else If boolUp Then
    tc = Ucase(c)
    Else tc = LCase(c)
    End If
    strOut = strOut & tc
    boolUp = False
    End If
    Next
    ProperCase = strOut
    End Function %>

    this function is put into an include file, and it uppercases a horse's
    name's first letter, and lowercases the rest, being called this way:

    response.write left(ProperCase(rs1("horsename")),14)

    What happens is when there are no more horse's names to be drawn from
    the database, that's when I get this Exception occured error

    thx for help
    Muench

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    J. Muenchbourg Guest

  2. Similar Questions and Discussions

    1. Error Occured While Processing Document
      I just installed ColdFusion 6.1 today on a Windows 2000 Server running IIS 5.0. I configured it to use IIS as the external server. The installation...
    2. error occured while processing request
      i just want to know what is mean by elemenet LOCALE is undefined in REQUEST ? i try to click to server debug and the result is came out with this...
    3. An unhandled exception has occured Unknown Server tag
      Hi, I am using ASP.Net 2.0 Beta 2. I have a class which inherits from "System.Web.UI.WebControls.Label" class. I have added that class in a...
    4. Getting the last query when an error occured
      HI ! Well, another one ! :) Yes, once again a little question for the newsgroup ! So i begin my explanation : with ESQL/C As all my "C"...
    5. Exception Occured only on one record
      I'm getting an "exception occured" error pointing to this line : <%=Replace(Replace(rs1("racelength"),"D","")," ","") %> ..when all the other...
  3. #2

    Default Re: Exception occured error

    Add a line to verify that the Len(strIn) > 0
    J. Muenchbourg wrote:
    > I'm getting an Exception occured error on line 4 (For i =1...)
    >
    > <% Function ProperCase(strIn)
    > strOut = ""
    IF Len(strIn) > 0 then
    > boolUp = True
    > For i = 1 To Len(strIn)
    > c = Mid(strIn, i, 1)
    > if c = " " or c = "'" or c = "-" then
    > strOut = strOut & c
    > boolUp = True
    > Else If boolUp Then
    > tc = Ucase(c)
    > Else tc = LCase(c)
    > End If
    > strOut = strOut & tc
    > boolUp = False
    > End If
    > Next
    End If
    > ProperCase = strOut
    > End Function %>
    >
    Bob


    Bob Barrows Guest

  4. #3

    Default Re: Exception occured error

    > response.write left(ProperCase(rs1("horsename")),14)

    Did you try:

    response.write(rs1("horsename"))

    Is there a value there?
    > What happens is when there are no more horse's names to be drawn from
    > the database, that's when I get this Exception occured error
    Maybe you should be testing for EOF!??!? How are you looping through these
    horsenames? Maybe you could show more code, and we could show you how to
    fix it...


    Aaron Bertrand - MVP Guest

  5. #4

    Default Re: Exception occured error

    I'm sure you've had a similar problem before. What happens if the horsename
    is null?
    If it is null then your line Len(strIn) is asking for the length of a null
    string... which is invalid.
    You need to test for null first.

    Function ProperCase strIn
    if isNull(strIn) then Exit Function

    OR

    Function ProperCase strIn
    strIn=strIn & "" 'That'll turn a null into an empty string. But
    be careful, an empty string may not work with the rest of your code.



    OR

    response.write left(ProperCase(rs1("horsename") & ""),14) ' Again, empty
    string

    "J. Muenchbourg" <anonymous@devdex.com> wrote in message
    news:eqQhdIMQDHA.3192@TK2MSFTNGP10.phx.gbl...
    > I'm getting an Exception occured error on line 4 (For i =1...)
    >
    > <% Function ProperCase(strIn)
    > strOut = ""
    > boolUp = True
    > For i = 1 To Len(strIn)
    > c = Mid(strIn, i, 1)
    > if c = " " or c = "'" or c = "-" then
    > strOut = strOut & c
    > boolUp = True
    > Else If boolUp Then
    > tc = Ucase(c)
    > Else tc = LCase(c)
    > End If
    > strOut = strOut & tc
    > boolUp = False
    > End If
    > Next
    > ProperCase = strOut
    > End Function %>
    >
    > this function is put into an include file, and it uppercases a horse's
    > name's first letter, and lowercases the rest, being called this way:
    >
    > response.write left(ProperCase(rs1("horsename")),14)
    >
    > What happens is when there are no more horse's names to be drawn from
    > the database, that's when I get this Exception occured error
    >
    > thx for help
    > Muench
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Tom B Guest

Posting Permissions

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

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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139