here i write a code to convert user given dob is stored as a age in db
but it shows a error --------------Failed to convert parameter value from a String to a Int32.
i use stored procedure for it
in .CS button _click
cmd.Parameters.Add("@age", SqlDbType.Int).Value = at.Text;
in stored procedure
@age int-----------------datatype
in table
age int
public int Age(DateTime dt)
{
DateTime today = DateTime.Today;
int age = today.Year - dt.Year;
if (dt > today.AddYears(-age))
age--;
return age;
}
protected void at_TextChanged(object sender, EventArgs e)
{
int age = Age(Convert.ToDateTime(at.Text));
Response.Write("Age:" + age);
Label8.Text = "Age" + age;
}