Asp.Net Class - problem returning html string value -


I am trying to return an HTML string to my class which I assign to an aspx page for control : This Div 1.InHtmlL = class.News ();

However, my catch code is always returning the 'Novellou' message.

The code works fine outside the classroom.

When I reader linesHTMLStr.Append (reader ["title"]. To comment. ToString ()); I can get back the string on my calling code, do I have to do more to use the readers in the classes?

Nameshot Conference {

  Public Class Conf {Private String Connection StringBMP = Web Configuration Manager. Connection String ["ConfBMP"]. ConnectionString; Public String News () {SqlConnection conn = New SqlConnection (connectionStringBMP); SqlCommand CMD = New SQL Commands ("Spawnews", Con?); Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue ("@ number", 2); SqlDataReader Reader; Try {conn.Open (); Reader = CMD Spare reader (); StringsbilderHTMLST = new stringbilder (""); While (reader.Read ()) {htmlStr.Append ("& lt; div class = 'news' & gt;"); ToString () + "'alt ='" + Reader ["ThumbnailText"]. ToString () + "'' ' ToString () + "/" + Reader ["Photo"]. ToString () + "'& gt;"); HtmlStr.Append ("& Lt; a href = news.aspx? P =" + Reader ["id"] + "& gt;"); htmlStr.Append (reader ["title"] ToString ()); htmlStr.Append "& Lt; / a & gt;"); htmlStr.Append ("& lt; / div>");} string html string = htmlStr.ToString (); reader.Close (); return html string;} Hold (exception mistake) {HttpContext.Current.Response.Write (err.Message); String Navyel = "No Value"; Return Navyel; } Finally {conn.Close ();}}}  

}

Get a closer look at the exception. Reader ["Title"] may be null .


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -