I\'m attempting to use the DataSet designer to create a datatable from a query. I got this down just fine. The query used returns a nullable datetime column from the datab
I did this to insert value NULL
in a DateTime
column,
assuming that I have a nullable DateTime
column in Database, I retrieved some data from the database in an object called response
and I want to insert nullable DateTime
value in the DataSet column that called RenewDate
:
// create anew row of the same type of your table row
var rw = ds.StudentActionPrintDT.NewStudentActionPrintDTRow();
// check for null value
if(!response.RenewDate.HasValue)
{
// if null, then the let DataSet to set it null by it's own way
rw.SetRenewDateNull();
}
else
{
// if not null set value to the datetime value
rw.RenewDate = response.RenewDate.Value;
}
// add the created row to the dateset [DataSetName].[ColumnName].Add[ColumnName]Row([The Created Row]);
ds.StudentActionPrintDT.AddStudentActionPrintDTRow(rw);