给你举个例子吧:
代码是我手写的,没有开vc,只做个参考思路……
string str = @"<table>";
SqlConnection conn = new SqlConnection("server=(local);uid=sa;pwd=;database=pubs");
conn.Open();
SqlCommand comm = new SqlCommand("select * from authors", conn);
SqlDataReader dr = comm.ExecuteReader();
while(dr.Read())
{
str += @" <tr><td>"+dr["au_id"].ToString();
str += @"</td><tr>";
}
str += @"</table>";
Response.Write(str);