Print Page | Close Window

Writing nulls

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9406
Printed Date: 28 March 2026 at 8:59pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Writing nulls
Posted By: jimidy
Subject: Writing nulls
Date Posted: 30 January 2004 at 7:09pm

I'm trying to write this content management system, it works fine except when I try to edit a page which has no data it returns an error..   Is this to do with needing to write nulls to the database?

The error is in my SQL on the line in red, any ideas? many thanks in advance..

<%
 showpage = cint(request.querystring("page"))
 if showpage = 0 then
  showpage = 1
 end if
 
 
 
 'create the SQL statement
 sql = "Select * from Pages where Page_Id = 2"
 ' populate the recordset
 rs.open sql,myconn,3,3
 Dim retRecords
 Dim retRecords2
 retRecords=rs("Page"&showpage&"")
 retRecords2=Replace(retRecords, "<BR>" & vbcrlf, vbcrlf)
%> 

'

  • Error Type:
    Microsoft VBScript runtime (0x800A005E)
    Invalid use of Null: 'Replace'
    /wn008/project/site/admin/editpage2.asp, line 296

    '



  • -------------
    www.srp.me.uk



    Replies:
    Posted By: Semikolon
    Date Posted: 30 January 2004 at 7:18pm
    you could maybe cheat a bit.. create a variable and if that variable is null set it to something.. if you understand what i mean


    Posted By: ljamal
    Date Posted: 31 January 2004 at 8:43am
    Replace
    retRecords2=Replace(retRecords, "<BR>" & vbcrlf, vbcrlf)
    with

    if not IsNull(retRecords2) then
    retRecords2=Replace(retRecords, "<BR>" & vbcrlf, vbcrlf)
    end if







    -------------
    L. Jamal Walton

    http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


    Posted By: jimidy
    Date Posted: 31 January 2004 at 11:07am

    Originally posted by ljamal ljamal wrote:

    Replace
    retRecords2=Replace(retRecords, "<BR>" & vbcrlf, vbcrlf)
    with

    if not IsNull(retRecords2) then
    retRecords2=Replace(retRecords, "<BR>" & vbcrlf, vbcrlf)
    end if


     

    Nice one man...

    It was

    if not IsNull(retRecords) then
    retRecords2=Replace(retRecords, "<BR>" & vbcrlf, vbcrlf)
    end if

    but you inspired it, thanks mate..



    -------------
    www.srp.me.uk


    Posted By: ljamal
    Date Posted: 31 January 2004 at 9:33pm
    I assume that you are using this to display test submitted from form field. I developed a generic function to handle it.


    Function DisplayText(varText)
    varText = Trim(Replace(" "&varText,vbcrlf,"<br>"))
    End Function


    -------------
    L. Jamal Walton

    http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


    Posted By: jimidy
    Date Posted: 31 January 2004 at 10:04pm
    nice one..  thanks a lot man.. 

    -------------
    www.srp.me.uk


    Posted By: MorningZ
    Date Posted: 01 February 2004 at 2:09am

    or you could also just

    retRecords2=Replace("" & retRecords, "<BR>" & vbcrlf, vbcrlf)

    Even though i'd prefer/do-use a function method like jjamal (even though he has his function wrong, lol)

    Function DisplayText(varText)
      varText = Trim(Replace(" "&varText,vbcrlf,"<br>"))
    End Function

    should be

    Function DisplayText(varText)
       DisplayText = Trim(Replace(" "&varText,vbcrlf,"<br>"))
    End Function

    oops :)



    -------------
    Contribute to the working anarchy we fondly call the Internet



    Print Page | Close Window

    Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
    Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net