C#: Object reference not set to an instance of an object.
- by Vinzcent
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