| Author |
Topic Search Topic Options
|
jimidy
Groupie
Joined: 05 October 2003
Status: Offline
Points: 54
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Semikolon
Senior Member
Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
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
|
|
|
 |
jimidy
Groupie
Joined: 05 October 2003
Status: Offline
Points: 54
|
Post Options
Thanks(0)
Quote Reply
Posted: 31 January 2004 at 11:07am |
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
|
 |
ljamal
Mod Builder Group
Joined: 16 April 2003
Status: Offline
Points: 888
|
Post Options
Thanks(0)
Quote Reply
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
|
|
|
 |
jimidy
Groupie
Joined: 05 October 2003
Status: Offline
Points: 54
|
Post Options
Thanks(0)
Quote Reply
Posted: 31 January 2004 at 10:04pm |
nice one.. thanks a lot man..
|
|
www.srp.me.uk
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
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
|
 |