troubleshooting Question

Creating a content management system using ASP.NET (C#) - Unable to display HTML pulled from Access Database

Avatar of Ayanni
Ayanni asked on
C#ASP.NETMicrosoft Development
12 Comments1 Solution189 ViewsLast Modified:
I've created a content management interface to allow content to be edited/changed.  The HTML/text editor I used was Xinha.  This part is working fine.  The problem I am now having is pulling the data and having it display on the web page.  

I've been stuck for days and I'm going crazy.

Everything seems to be working fine - connecting to the database and I've even been able to pull back the data when I do a response.write.  The problem occurs when I attempt to use the variable that contains the html and attempt to display it.  I get an error.

Database I'm using is Access and I'm using ASP.NET 1.1.

The code that I have in calendar.aspx.cs is:

public void Page_Load(object sender, System.EventArgs e)
                        string htmltext;
                  this.cmdWebDisplay = new System.Data.OleDb.OleDbCommand();

                  // Put user code to initialize the page here

                  using(OleDbConnection connection = new OleDbConnection(Configuration.ConnectionInfo))
                              this.cmdWebDisplay.CommandText = "Select WebContent.Content FROM WebContent WHERE ((WebContent.PageID)= 1 ) AND ((WebContent.ContentID) = 1)";
                              this.cmdWebDisplay.Connection = connection;

                              System.Data.OleDb.OleDbDataReader oleReader = this.cmdWebDisplay.ExecuteReader();

                              while (oleReader.Read())

                                    htmltext = oleReader["Content"].ToString();


                        catch (OleDbException ex)



And then in the actual .aspx page I'm attempting to reference that htmltext variable.

I'm attempting to reference it by using <%=htmltext%> in my HTML.

When I run it, I get the following error:
CS0103:  The name "htmltext" does not exist in the class or namespace 'ASP.calendar_aspx

Seems as if that code hasn't run before the page is loaded.  What am I missing?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros