I have written a database connection –
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
<title>SQL Authentication</title>
<h1>title</h1>
</head>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDbConn"].ToString()))
{
SqlCommand cmd = new SqlCommand("SELECT * FROM dbo.table", cn);
...etc...
...etc...
</script>
<html>
How can I use this function within the html of a web page, as currently it is taking all the results from the database, and it is filling the whole page, and any modifications I make to the html e.g. <h1>Title</h1> are coming out underneath the table of database results?
The preferred way of displaying data in WebForms is with data bound controls such as the GridView. There are numerous tutorials on how to do this. Start with the ones on http://asp.net.
ASP.NET Data Controls