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:
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???
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.

probably have to call it and then use javascript:  Document.Write(
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:

<!--#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" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Members Page</title>
<link href="/style.css" rel="stylesheet" type="text/css" />
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.
Change this:



if not rsmeminfo.eof and not rsmeminfo.bof then
response.write rsMemInfo("PageContent")
end if
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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

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.
RCairns54Author Commented:
Thanks! That is exactly what I needed!
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

From novice to tech pro — start learning today.