Question

Here I am using c# code for retrieving the data from the database to spreadsheet when I am writing the query (SqlCommand) to retrieve all columns and distinct for one column it's showing error that

Cannot set Column 'date' to be null. Please use DBNull instead.

Here is my query :

  select distinct on columnname *
  from tablename

Where I am missing can anyone help me?

Was it helpful?

Solution

When working back the other way (an Excel Table range => C#) we found that the SpreadsheetGear loads the row of a table array into the header information of DataTable. We couldn't read the cell contents in the first row as table data. To get around this we leave the first row of a table extracted from a spreadsheet as blank then start extracting data from the second row and below.

Perhaps your problem is the reverse of this issue - DataTable (and the SpreadsheetGear API) want you to fill the first row with column heading information and then populate data in subsequent rows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top