title: index out of range exception was unhandled in c#
body: <p>This is my code to retrieve currently inserted product_ID but i got the exception here - "Index Out of range" Product_ID</p>
  
  <pre><code>    public int GetProductIDD()
      {
          int productID = 0;
  
          con.Open();
          string str = "SELECT MAX(Product_ID) FROM AddProduct";
          cmd = new SqlCommand(str, con);
          SqlDataReader rd = cmd.ExecuteReader();
  
          while (rd.Read())
          {
              productID = Convert.ToInt32(rd["Product_ID"]);
          }
  
          return productID;
      }
  </code></pre>
  
  <p>My database table AddProduct as follows-</p>
  
  <pre><code>Product_ID   Product_Name  Vendor_ID
  -----------------------------------------
  1            asd           3 
  </code></pre>
  
  <p>Thanks in advance...</p>