Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Writing nulls
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Writing nulls

 Post Reply Post Reply
Author
jimidy View Drop Down
Groupie
Groupie


Joined: 05 October 2003
Status: Offline
Points: 54
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimidy Quote  Post ReplyReply Direct Link To This Post Topic: Writing nulls
    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
    Back to Top
    Semikolon View Drop Down
    Senior Member
    Senior Member


    Joined: 09 September 2003
    Location: Norway
    Status: Offline
    Points: 1718
    Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post 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
    Back to Top
    ljamal View Drop Down
    Mod Builder Group
    Mod Builder Group


    Joined: 16 April 2003
    Status: Offline
    Points: 888
    Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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





    Back to Top
    jimidy View Drop Down
    Groupie
    Groupie


    Joined: 05 October 2003
    Status: Offline
    Points: 54
    Post Options Post Options   Thanks (0) Thanks(0)   Quote jimidy Quote  Post ReplyReply Direct Link To This Post 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
    Back to Top
    ljamal View Drop Down
    Mod Builder Group
    Mod Builder Group


    Joined: 16 April 2003
    Status: Offline
    Points: 888
    Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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
    Back to Top
    jimidy View Drop Down
    Groupie
    Groupie


    Joined: 05 October 2003
    Status: Offline
    Points: 54
    Post Options Post Options   Thanks (0) Thanks(0)   Quote jimidy Quote  Post ReplyReply Direct Link To This Post Posted: 31 January 2004 at 10:04pm
    nice one..  thanks a lot man.. 
    www.srp.me.uk
    Back to Top
    MorningZ View Drop Down
    Senior Member
    Senior Member
    Avatar

    Joined: 06 May 2002
    Location: United States
    Status: Offline
    Points: 1793
    Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
    Back to Top
     Post Reply Post Reply

    Forum Jump Forum Permissions View Drop Down

    Forum Software by Web Wiz Forums® version 12.08
    Copyright ©2001-2026 Web Wiz Ltd.


    Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
    About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

    Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
    Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

    Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

    Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.