C#: Object reference not set to an instance of an object.

Posted by Vinzcent on Stack Overflow See other posts from Stack Overflow or by Vinzcent
Published on 2010-04-27T08:09:21Z Indexed on 2010/04/27 8:13 UTC
Read the original article Hit count: 533

Filed under:
|

Hey,

I get the following error:

Object reference not set to an instance of an object

This is my C Sharp code:

      DataTable tableAcces = dsAcces.Tables["dsPrinterAcces"];
      DataTable tableMDF = dsAcces.Tables["dsPrinterMDF"];
      DataRow newrow = null;


      foreach(DataRow dr in tableAcces.Rows)
       {
           newrow = tableMDF.NewRow();

        newrow["PRINTER_ID"] = dr["PRINTER_ID"];
        newrow["MERK"] = dr["MERK"];
        newrow["MODEL"] = dr["MODEL"];
        newrow["LOKAAL_ID"] = dr["LOKAAL_ID"];

        tableMDF.Rows.Add(newrow);
      }

      daMDF.Update(dsMDF, "dsPrinterMDF");
      lblSucces.Text = "Gelukt. De tabel printers is overgezet.";
    }

In this line, he throws the error:

newrow = tableMDF.NewRow();

Thanks a lot,

Vincent

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET