Click to See Complete Forum and Search --> : load date from sql server


dummyagain
July 27th, 2006, 12:55 PM
I would like to make a table with the content loaded from the SQL Server.

FOr example there are 5 records loaded from the db,

1 ABC 10
2 CDE 34
3 RTG 76
4 HRE 76
5 GRE 23

As I use asp to get the data from sql server, how i can insert html code in the ASP.NET code?

Can you please show me a simple example?

Thank you

hedge_fund
July 27th, 2006, 08:02 PM
You have not really specified exactly what you are looking to do, but here is a quick example:


StringBuilder htmlBuilder = new StringBuilder();
//Open up the connection to the sql server...
using(SqlDataReader dbReader = sqlConn.ExecuteReader())
{
while(dbReader.Read())
{
htmlBuilder.Append(dbReader.ReadString(0));
}
}

this.controlToPopulate.Text = htmlBuilder.ToString();

Shuja Ali
July 28th, 2006, 02:38 AM
Have you chceked the DataGrid control yet? I think that would be easier to use and you don't have to write any HTML for that.