DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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, 11:20 AM
  2. Still a problem sending email from ASP.Net
    By George Ceaser in forum ASP.NET
    Replies: 0
    Last Post: 10-25-2002, 10: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, 03:39 AM
  4. problem with running asp.net application
    By evgeny in forum ASP.NET
    Replies: 0
    Last Post: 05-08-2002, 04:28 AM
  5. dropdownlist problem in asp.net
    By vijay in forum ASP.NET
    Replies: 1
    Last Post: 05-06-2002, 11:58 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links