asp.net 2.0 weird datatable problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: asp.net 2.0 weird datatable problem

  1. #1
    Join Date
    Nov 2005
    Posts
    1

    asp.net 2.0 weird datatable problem

    Hi folks!
    I am experiencing to me a weird problem with my datatables. I have a dataset which contains multiple datatables, generated from stored procedures and tables by the drag and drop interface in VS 2005. However when I am populating these tables i get an error message saying

    A first chance exception of type 'System.NullReferenceException' occurred in Server.DLL

    Server.DLL is my business layer. It appears that this appears on a non-regular basis but by stepping through my code I have located the error to be in the following snippet

    IssuesDataset.IssueReportsReadableDataDataTable returnTable;
    DataTable tempTable;

    returnTable = new IssuesDataset.IssueReportsReadableDataDataTable();

    tempTable = sqlServerImpersonation.ExecuteDataset([REMOVED BY AUTHOR, GETS A DATASET]).Tables[0];

    //Here is the error thrown, sometimes the debugger points out that DataRow //dataRow is the reason, other times the keyword in and other times again //the bracket below the foreach statement
    foreach (DataRow dataRow in tempTable.Rows)
    {
    returnTable.ImportRow(dataRow);
    }

    return returnTable;

    The datatable is populated and it works, but this error is driving me insane...

    Hopefully someone has an idea about what's causing this.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I would add code to ensure that tempTable and tempTable.Rows are not null:
    Code:
    tempTable = sqlServerImpersonation.ExecuteDataset(...).Tables[0];
    if (tempTable != null)
    {
        if (tempTable.Rows != null)
        {
            foreach (DataRow dataRow in tempTable.Rows)
            {
                returnTable.ImportRow(dataRow);
            }
        }
    }
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 0
    Last Post: 10-06-2005, 12:20 PM
  2. Still a problem sending email from ASP.Net
    By George Ceaser in forum ASP.NET
    Replies: 0
    Last Post: 10-25-2002, 11:03 AM
  3. Free ASP.NET Web Matrix Design/Editor Tool Released
    By ASPSmith Training in forum dotnet.announcements
    Replies: 0
    Last Post: 06-18-2002, 04:39 AM
  4. problem with running asp.net application
    By evgeny in forum ASP.NET
    Replies: 0
    Last Post: 05-08-2002, 05:28 AM
  5. dropdownlist problem in asp.net
    By vijay in forum ASP.NET
    Replies: 1
    Last Post: 05-06-2002, 12:58 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