This is about as simple as it gets:
<%@ Page Language="C#" %>
<html>
<head>
<title>Web Form to DB</title>
</head>
<body>
<form id="myForm" runat="server">
Name:
<asp:TextBox runat="server" ID="txtName" />
<br />
Age:
<asp:TextBox runat="server" ID="txtAge" />
<br />
<asp:Button runat="server" onclick="HandleInsert" Text="Save" />
</form>
</body>
</html>
<script runat="server">
public void HandleInsert(object sender, EventArgs e)
{
string name = txtName.Text;
int age = int.Parse(txtAge.Text);
string strCommand = "INSERT INTO People (PersonName, PersonAge) VALUES (@PersonName, @PersonAge)";
string strConnection = @"Data Source=MyMachineName\SQL2005;Initial Catalog=TestDB;Integrated Security=True";
var conn = new System.Data.SqlClient.SqlConnection(strConnection);
var cmd = new System.Data.SqlClient.SqlCommand(strCommand, conn);
cmd.Parameters.AddWithValue("PersonName", name);
cmd.Parameters.AddWithValue("PersonAge", age);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
</script>
You'll have to make sure the "People" table exists first. And modify the connection string to point to your database.