title: How to programmatically set a datetime column value in postgre SQL server table to null in C#
body: <p>What am trying to do is I have an excel file with some data, i am reading the file and filling the data into a dataTable in C#. Now i have to construct an insert query to insert the excel data into Postgre SQL table. One of the column (DateTime type)values, if empty needs to be set to null in the table. I am trying to do that in C# but doesn't work. The constructed insert query shows the cell value as '' and when I am trying to execute the query the server is throwing an exception "invalid input syntax for type timestamp: """</p>
  
  <pre><code>            foreach (DataRow currentDataRow in dataTable.AsEnumerable())
              {
  
                  if (string.IsNullOrEmpty(Convert.ToString(currentDataRow["Closed"])))
                  {
                      currentDataRow["Closed"] = DBNull.Value;//Doesnot work
  
                  }
              }
  </code></pre>