load date from sql server
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
[377 byte] By [
dummyagain] at [2007-11-20 0:01:28]

# 1 Re: load date from sql server
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();
# 2 Re: load date from sql server
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.