title: How to Fix This "system.nullreferenceexception object reference not set to an instance of an object" in mvc web service
body: <p><strong>In My Controller</strong>    </p>
  
  <pre><code>public string Post(Order od)
          {
  
              string result = "";
  
              Database newDB= new Database("New");
              try
              {
  
                newDB.Execute(@"insert into TABLE_A(BranchID,CustomerName,BirthDate,BirthPlace) 
                  Select @0,@1,@2,@3",
                  new object[] {od.BranchID,od.CustomerName,od.BirthDate,od.BirthPlace});
  
  
                  newDB.CloseSharedConnection();
                  result = "succes";
              }
              catch (Exception Ex)
              {
                  result = Ex.Message;
  
              }
  
              return result;
          }
  </code></pre>
  
  <p>in error message</p>
  
  <blockquote>
    <p>System.NullReferenceException: Object reference not set to an instance
    of an object"</p>
  </blockquote>
  
  <p>I try created a new object odr:</p>
  
  <pre><code>public string Post(Order od)
          {
  
              string result = "";
              Order odr = new Order();
              Database newDB= new Database("New");
              try
              {
  
                Log.Info("REQ:" + od.BranchID + "|" + od.CustomerName + "|" + od.BirthDate + "|" + od.BirthPlace);
                newDB.Execute(@"insert into TABLE_A(BranchID,CustomerName,BirthDate,BirthPlace) 
                  Select @0,@1,@2,@3",
                  new object[] {odr.BranchID,odr.CustomerName,odr.BirthDate,odr.BirthPlace});
  
  
                  newDB.CloseSharedConnection();
                  result = "succes";
              }
              catch (Exception Ex)
              {
                  result = Ex.Message;
                  Log.Error(Ex)             
              }
  
              return result;
          }
  </code></pre>
  
  <p>but the data that I've post is null. Please help my problem :(</p>