I've been using some code very similar to the following to populate a gridview control:
using(SqlDataAdapter sqlDataAdapter =
new SqlDataAdapter("SELECT * FROM Table1",
"Server=.\\SQLEXPRESS; Integrated Security=SSPI; Database=SampleDb"))
{
using (DataTable dataTable = new DataTable())
{
sqlDataAdapter.Fill(dataTable);
this.dataGridView1.DataSource = dataTable;
}
}
I now want to take that grid view and sent the results in an e-mail in a html table. I believe I could work through this by using the gridview as a middle man (add results to gridview then draw html table cell by cell) but I was wondering if there's a way to take the results of an SQL query and draw it into a html table ready for e-mailing?
Summary: How can I query a database and have the results returned in such a way that I could draw a HTML table with them?