error index out of range exception was unhandled by user code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: error index out of range exception was unhandled by user code

  1. #1
    Join Date
    Mar 2008
    Posts
    110

    error index out of range exception was unhandled by user code

    You can for example enter the length and width of the web (VS.NET2005), when it runs out of range index error exception was unhandled by user code for chieudai

    Code:
    public class Tinh
        {
             private Int32 _quanhuyen;
             private String _diachiNha;
             private Double _chieudai;
             private Double _chieurong;         
             private Double _dientichDat;
        }
       
          public Int32 Quanhuyen
           {
                get { return _quanhuyen; }
                set { _quanhuyen = value; }
            }
     
           public String DiachiNha
            {
                 get { return _diachiNha; }
                 set { _diachiNha = value; }
             }
    
             public Double Chieudai
             {
                 get { return _chieudai; }
                 set { _chieudai = value; }
             }
    
             public Double Chieurong
             {
                 get { return _chieurong; }
                 set { _chieurong = value; }
             }
    
            public Double DientichDat
            {
               get { return _dientichDat; }
               set { _dientichDat = value; }
            }
    
        private Tinh DienTich(IDataReader dr, bool GetTotalRecords)
        {
           Tinh obj = new Tinh();
                      obj.Quanhuyen = (dr["Quanhuyen"] is DBNull) ? Int32.MinValue : (Int32)dr["Quanhuyen"];
                      obj.DiachiNha = (dr["DiachiNha"] is DBNull) ? String.Empty : (String)dr["DiachiNha"];
                      // bottom  line this error index out of range exception was unhandled by user code
                      obj.Chieudai = (dr["Chieudai"] is DBNull) ? Double.MinValue : (Double)dr["Chieudai"];   
                      obj.Chieurong = (dr["Chieurong"] is DBNull) ? Double.MinValue : (Double)dr["Chieurong"];
                 obj.DientichDat = (dr["DientichDat"] is DBNull) ? Double.MinValue :  (Double)dr["DientichDat"];
                      if (GetTotalRecords)
                         obj.TotalRecords = (dr["TotalRecords"] is DBNull) ? -1 : Globals.ConvertToInt32(dr["TotalRecords"]);
    
            return obj;
            }
    because you see help, or advice fixes
    Last edited by dong; 07-11-2012 at 03:02 AM.

Similar Threads

  1. An unhandled Security Exception
    By tjm1976 in forum .NET
    Replies: 1
    Last Post: 12-08-2005, 12:19 PM
  2. Microsoft's C++ bigotry
    By Phil Weber in forum .NET
    Replies: 632
    Last Post: 10-01-2003, 12:00 AM
  3. VS.Net and Code Behind
    By Chaitanya Marvici in forum ASP.NET
    Replies: 6
    Last Post: 07-21-2003, 09:15 AM
  4. Replies: 0
    Last Post: 04-28-2002, 07:07 PM
  5. Replies: 0
    Last Post: 04-03-2001, 04:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center