How do I display html data stored in an ntext or nvarchar(MAX) data type?

I am needing to store large amounts of HTML data in my SQL 2005 database. I have tried using ntext and nvarchar(MAX). I can get the data in the database but I have yet to be able to display it on an ASP web page.

Usually I would create a dataset and display data using this method:
<%=rsPage("PageContent")%>
This method works fine with a nvarchar(255) data type but this type is too small for what I am needing now. Can anyone please help???
RCairns54Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

silemoneCommented:
probably have to call it and then use javascript:  Document.Write(
0
RCairns54Author Commented:
Thank you, Im not sure how to do that. Here is a condensed version of the page and how I display data from a dataset:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/members_secure.asp" -->
<!--#include virtual="/dbConn.asp" -->
<%
Dim rsMemInfo__ColParam
rsMemInfo__ColParam = "1"
If (Session("Username") <> "") Then
  rsMemInfo__ColParam = Session("Username")
End If
%>
<%
Dim rsMemInfo
Dim rsMemInfo_cmd
Dim rsMemInfo_numRows

Set rsMemInfo_cmd = Server.CreateObject ("ADODB.Command")
rsMemInfo_cmd.ActiveConnection = dbConn_STRING
rsMemInfo_cmd.CommandText = "SELECT * FROM dbo.webpage WHERE User1 = ?"
rsMemInfo_cmd.Prepared = true
rsMemInfo_cmd.Parameters.Append rsMemInfo_cmd.CreateParameter("param1", 200, 1, 255, rsMemInfo__ColParam) ' adVarChar

Set rsMemInfo = rsMemInfo_cmd.Execute
rsMemInfo_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Members Page</title>
<link href="/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%=(rsMemInfo.Fields.Item("PageContent").Value)%>
</body>
</html>
<%
rsMemInfo.Close()
Set rsMemInfo = Nothing
%>

The line between the body tags: <%=(rsMemInfo.Fields.Item("PageContent").Value)%> would normaly display as html from smaller data types but for some reason when using ntext or nvarchar(MAX) it won't display.
0
BrandonGalderisiCommented:
Change this:

<%=(rsMemInfo.Fields.Item("PageContent").Value)%>

to:

<%
if not rsmeminfo.eof and not rsmeminfo.bof then
response.write rsMemInfo("PageContent")
end if
%>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rhodesbCommented:
There is a weird issue with the ADODB Recordset object in ASP where you can only access some large text field types (like memo in access and ntext in SQL server) one time and sometimes not to display.  The solution is to store the field in a variable first and then just display the variable.  Pretty straight forward and seems ridiculous but will likely fix the problem.
Dim PageContent
PageContent = rsMemInfo("PageContent")
 
<%=PageContent %>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RCairns54Author Commented:
Thanks a million! I have been trying to figure this out for quite some time before posting on this website.
0
RCairns54Author Commented:
Thanks! That is exactly what I needed!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.