1. Table Structure from SQL Server (Express Edition) 

table_struct

2. Web.config

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <connectionStrings>
  <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
		<compilation debug="true" targetFramework="4.0"/>
	</system.web>
</configuration>

3. Web form

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="addrecord.aspx.cs" Inherits="addrecord" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <br />
    <table border="1" style="width:100% ; background-color:#123456;"><tr><td>
<div style="padding:10px; height:250px">
    <h3 style="text-align:center; color:White">ADD EMPLOYEE RECORD</h3>
<table cellspacing="10" style="margin:auto" >
<tr>
<td><asp:Label ID="Label6" runat="server" ForeColor="White" Text="ENAME"></asp:Label></td>
<td><asp:TextBox ID="TextBox5" runat="server" Width="300"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label7" runat="server" ForeColor="White" Text="EDEPT NAME"></asp:Label></td>
<td><asp:TextBox ID="TextBox6" runat="server" Width="300"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label9" runat="server" ForeColor="White" Text="DOB"></asp:Label> 
    
</td>
<td><asp:TextBox ID="TextBox7" runat="server" Width="300"></asp:TextBox></td>
</tr>
<tr align="right">
<td colspan="2"> <asp:Label ID="Label10" ForeColor="Green" runat="server"></asp:Label>
 <asp:Button ID="Button2" runat="server" Text="SAVE" onclick="Button2_Click"></asp:Button><br />
 </td>
 </tr>
</table>
 </div>
 </td></tr></table>      
</asp:Content>

4. Code Behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class addrecord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    
    protected void Button2_Click(object sender, EventArgs e)
    {
        SqlConnection cnn = new SqlConnection();
        cnn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "insert into employee(ename,edep,edoj,dob) values(@ename,@edep,@edoj,@dob)";
        cmd.Parameters.AddWithValue("@ename", TextBox5.Text);
        cmd.Parameters.AddWithValue("@edep", TextBox6.Text);
        cmd.Parameters.AddWithValue("@dob", TextBox7.Text);
        cmd.Parameters.AddWithValue("@edoj", Convert.ToDateTime(DateTime.Now));
        if (TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text=="")
        {
            Label10.Text = "Error!! required field is empty";
            Label10.ForeColor = System.Drawing.Color.Red;
        }
        else
        {
            cmd.Connection = cnn;
            cnn.Open();
            int r = cmd.ExecuteNonQuery();
            if (r != 0)
            {
                Label10.Text = "Record Successfully Saved";
                Label10.ForeColor = System.Drawing.Color.Green;
            }
            cnn.Close();

            TextBox5.Text = "";
            TextBox6.Text = "";
            TextBox7.Text = "";
        }
    }
}

5. Run program

6. Insert record & click to save

asp_addrecord

 

Record Successfull save..

asp_addsuccess

 

7. Check your database

db_ado