title: How to insert null in SQL database for using C# object properties of type decimal or string or int
body: <p>I have Employee class with the below properties</p>
  
  <pre><code>       class Employee{
  
             public int?  EmployeeId {get; set;}
             public string Name{get; set;}
             public decimal? Salary{get; set;}
         }
  </code></pre>
  
  <p>I have created an object </p>
  
  <pre><code>Employee emp = new Employee(){EmployeeId = 10, Name = "Peter", Salary = 1000.0}
  </code></pre>
  
  <p>I have written below Insert query inside <strong>LoadEmployee()</strong> method to insert Employee object data into Employee table </p>
  
  <pre><code>public static void LoadEmployee(Employee obj){
       string sqlString = @"Insert into dbo.Employee (EmpId, Name, Salary values ('"+ obj.EmployeeId + "','"+ obj.Name +  "','"+obj.Salary"')";
       SqlCommand queryCommand = new SqlCommand(sqlString, this.sdwDBConnection);
       queryCommand.Executereader();     
  }
  </code></pre>
  
  <p>When we have non null values for EmpId, Name or Salary, the code is working fine. The challenge is that Name or Employee Id or Salary can be null. I am able to assign null value to Salary with the below statement.</p>
  
  <pre><code>  emp.Salary = null;
    emp.Name = null;
  </code></pre>
  
  <p>After inserting Insert query, when I verify in db, Name is updated with string value "null"  and  Salary is updated as 0. I am expecting null values to be inserted to Name and Salary fields in Employee table.</p>
  
  <p>Please help me how to insert null for Name or Salary in the database in this situation.</p>