Wrox Programmer Forums
|
BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
This is the forum to discuss the Wrox book Professional ASP.NET 3.5: In C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470187579
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2009, 09:49 AM
Registered User
 
Join Date: Feb 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Angry a question from a beginner

code follows

string connectionString =
WebConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
string sql = "SELECT * FROM Employees";
SqlCommand cmd = new SqlCommand(sql, con);
// Open the Connection and get the DataReader.
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
// Cycle through the records, and build the HTML string.
StringBuilder htmlStr = new StringBuilder("");
while (reader.Read())
{
htmlStr.Append("<li>");
htmlStr.Append(reader["TitleOfCourtesy"]);
htmlStr.Append(" <b>");
htmlStr.Append(reader.GetString(1));
htmlStr.Append("</b>, ");
htmlStr.Append(reader.GetString(2));
htmlStr.Append(" - employee from ");
htmlStr.Append(reader.GetDateTime(6).ToString("d") );
htmlStr.Append("</li>");
}
// Close the DataReader and the Connection.
reader.Close();
con.Close();
// Show the generated HTML code on the page.
HtmlContent.Text = htmlStr.ToString();

.................................................. ...

what is HtmlContent here??
if i want to replace it.....what can i use???
 
Old June 18th, 2009, 10:36 AM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Your code snippet basically build up a list for your html page using the string builder function.

If you want to change the content, then you would have to replace what is inside the while (reader.Read()) loop.

Hope this is your question .





Similar Threads
Thread Thread Starter Forum Replies Last Post
beginner C++ question p62 proslambano BOOK: Ivor Horton's Beginning Visual C++ 2005 4 February 7th, 2007 04:23 PM
Beginner Question dkr72 Excel VBA 1 January 18th, 2005 09:37 AM
Beginner question on getting only certain elements EstherMStrom XSLT 5 December 10th, 2004 04:38 PM
beginner question saudyonline General .NET 2 September 21st, 2004 01:56 AM
Stupid Question from a BEGINNER Shappy Access VBA 1 May 11th, 2004 03:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.