Raju Fodse

Raju Fodse

  • 1.5k
  • 244
  • 31k

object reference not set to an instance of an object error

Sep 20 2018 3:03 AM
I have controller to save record. and my code is as follows
 
  1. [HttpPost]  
  2.         public ActionResult CreateP3(Process process)  
  3.         {  
  4.             var tr = process.StageID + process.PIPENO + process.Status;  
  5.             var checkme = (from x in db.Processes  
  6.                            where x.StageID + x.PIPENO + x.Status == tr && x.Status == "OK"  
  7.                            select x).ToList();  
  8.             if (checkme.Count > 0)  
  9.             {  
  10.                 ModelState.AddModelError("PIPENO""You are trying Duplicate Pipe Entry");  
  11.             }  
  12.             if (ModelState.IsValid)  
  13.             {  
  14.                 if (process.PipeAl.Order.THK > 1)  
  15.                 {  
  16.                     process.MPP = 20;  
  17.                 }  
  18.                 else  
  19.                 {  
  20.                     process.MPP = 1;  
  21.                 }  
  22.                 process.CuttingSpeed = (process.ActualMeter*1000)/process.CuttingTime;  
  23.                 db.Processes.Add(process);  
  24.                 db.SaveChanges();  
  25.                 return RedirectToAction("IndexP3");  
  26.             } 
 But I get object reference not set on an instance of an object error. Pls help
 
 
 

Answers (5)