Function Runtime error

Results 1 to 6 of 6

Thread: Function Runtime error

  1. #1
    Raul Ignis Guest

    Default Function Runtime error

    Hi,<BR><BR>When I try updating the database I keep receiving the following error<BR><BR>Error Type:<BR>Microsoft VBScript runtime (0x800A005E)<BR>Invalid use of Null<BR>functions.asp, line 4<BR><BR>The code for that file is:<BR>Function valid_sql(s)<BR><BR>For i = 1 To Len(s)<BR> If Mid(s, i, 1) = "&#039;" Then<BR> temp = temp + "&#039;"<BR> End If<BR> <BR> temp = temp + Mid(s, i, 1)<BR>Next<BR><BR><BR>valid_sql= Trim(temp)<BR><BR> <BR>End Function<BR><BR><BR>What is wrong? Please Help.<BR>

  2. #2
    tof Guest

    Default which is line 4?

    but u should be using REPLACE anyway. look it up.<BR>

  3. #3
    Raul Ignis Guest

    Default Sorry. Line 4 Noted and Shown

    Ho Tof,<BR><BR>Sorry about that.<BR><BR>This is line 4<BR>For i = 1 To Len(s)<BR><BR>What do you mean by using replace

  4. #4
    . Guest

    Default Replace()

    It&#039;s a function...<BR>

  5. #5
    Join Date
    Dec 1969

    Default Invalid use of NULL

    It looks like you aren&#039;t passing a vailid string into you function. LEN(s) can not work if &#060;s&#062; is NULL.<BR><BR>You could test to see if &#060;s&#062; IsNull

  6. #6
    Eddie Campbell Guest

    Default RE: Function Runtime error

    As posted above, if all you want to do is get rid of &#039; marks, replace would be much better: s=replace(s,"&#039;",""). If you really want to carry on the way you had coded it, try like this as this will now deal with null values for s.<BR><BR>Function valid_sql(s) <BR>s=s & "" &#039; Turn any nulls into an empty string<BR>For i = 1 To Len(s) <BR> If Mid(s, i, 1) = "&#039;" Then <BR> temp = temp + "&#039;" <BR> End If <BR> temp = temp + Mid(s, i, 1) <BR>Next <BR>valid_sql= Trim(temp) <BR>End Function

Posting Permissions

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