[RESOLVED] DateTime DataColumn
I'm adding a DateTime DataColumn to a DataTable like this:
Code:
Dim colDate As DataColumn = New DataColumn("Date")
colDate.DataType = System.Type.GetType("System.DateTime")
dt.Columns.Add(colDate)
Then when I try to add it to my datatable, if the value is Nothing I get an error saying string was not recognized as a valid DateTime. I'm having trouble getting this to work. What would you do?
Thanks
Re: [RESOLVED] DateTime DataColumn
First up, do it the easy way:
vb.net Code:
dt.Columns.Add("Date", GetType(Date))
As for this error you mention, if it's telling you anything to do with Strings then you're doing it wrong because you should only be putting Date values or DBNull.Value into a Date column. Strings should never come into play at all. You're going to have to show us how you're putting the data into the column so that we can see exactly what you're doing wrong.