Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace WebApplication1
    public partial class dob : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        protected void Button1_Click(object sender, EventArgs e)
            SqlConnection con = new SqlConnection("Data Source=ADMIN-PC;Initial Catalog=testdb;User ID=sa;Password=Klogwiy8");
            SqlCommand com = new SqlCommand("insert into dob values('"+txtName.Text+"','','"+txtDOB.Text+"')");
            com.Connection = con;

        protected void Button2_Click(object sender, EventArgs e)

        protected void Button3_Click(object sender, EventArgs e)
            String Bir = txtdob2.Text;

            DateTime birth = Convert.ToDateTime(Bir);
            DateTime present = DateTime.Now;
            TimeSpan ts = birth - present;
            DateTime age = DateTime.MinValue.AddDays(ts.Days);
            Response.Write("Current age is : "+age.Year+" years " +age.Month+ " Months "+age.Day+" Days");
            if (age.Year > 58)
                Response.Write("This Employee has retired");
Updated 2-Feb-14 20:03pm
Bernhard Hiller 3-Feb-14 2:06am    
In which line?
Karthik_Mahalingam 3-Feb-14 2:29am    
r u sure in this page only you are getting the error ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900