title: Reading int values from SqlDataReader
body: <p>hi can anyone please help me with this fetching from database of int values im having difficulty in fetching int values , it works for varchar but not int can someone help me out please </p>
  
  <pre><code>if (int.TryParse(TxtFarmerCode.Text, out intValue))
  {
     using (SqlConnection sqlConn = new SqlConnection("Data Source=TANYA-PC;Initial Catalog=biore1;Integrated Security=True")) //here goes connStrng or the variable of it
     {
        sqlConn.Open();
        string sqlQuery = @"SELECT farmername,villagename,gender,farmsize FROM cottonpurchase WHERE farmercode = @code";
  
        using (SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn))
        {
           cmd.Parameters.Add("@code", SqlDbType.Int).Value = intValue;
           using (SqlDataReader reader = cmd.ExecuteReader())
           {;
              if (reader.Read())
              {
                 TxtFarmerName.Text = (string)reader[0];
                 TxtVillageName.Text = (string)reader[1];
                 TxtGender.Text = (string)reader[2];
              }
              else
                 MessageBox.Show("For Farmer Code " + intValue.ToString() + " there is no farmer in the database.");
           }
        }
     }
  }
  </code></pre>
  
  <p>i want to fetch txtfarmersize  which is int but dont know how to do it please help me?</p>