Skip to content
Loading
  • Sachin Singh
    +2
    your rdr[o] is returning an int, so you can't use getstring() method on that instead use this
     
    1. while (reader.Read())  
    2. {  
    3. string val =Convert.ToString( rdr.GetInt32(0));  
    4. txtAge.text=val;  
    5. }  
    +2
  • Bhavesh Vankar
    +2
    i have done it as below...
    and its working using textbox lost focus event...
     
    1. String birthdate = txtbod.Text;  
    2.  SqlConnection con = new SqlConnection(this.con);  
    3.   
    4.             SqlCommand cmd = new SqlCommand("Select DATEDIFF(YEAR,CONVERT(datetime,'" + birthdate + "',103),CONVERT(datetime,V_ISSUEDATE,103)) FROM MASTER_TABLE", con);  
    5.             con.Open();  
    6.             string year = Convert.ToString(cmd.ExecuteScalar());  
    7.             con.Close();  
    8.             txtage.Text = year;  
     
    +2