In the table type the
docdate column is defined as a
datetime data type -
[DocDate] [DateTime] NULL - and then in the DataTable definition, the
docdate column is defined as a string data type -
MoDetails.Columns.Add("docdate", GetType(String)).
In the
For Each loop the last two variables in the
Rows.Add command are spelt wrong.
In the For Each loop you create a string variable,
format_pubdate and then assign it to the
DateTime variable
pubdate before using it in the
Rows.Add command, this may be causing an issue.
Your code extract does not include a declaration nor an assignment for the
format_Docdate variable.
Some suggestions.
Change this line :
MoDetails.Columns.Add("docdate", GetType(String))
To :
MoDetails.Columns.Add("docdate", GetType(DateTime))
If the
pubdate field should be
the same in every row then change this line :
Dim pubdate As DateTime = format_pubdate
To:
Dim pubdate As DateTime = pubdate_value
and delete this line (change
dd-MM-yyyy to match your needs) :
Dim format_pubdate = pubdate_value.ToString("dd-MM-yyyy")
If the
pubdate field should be the
different in every row then change it to :
Dim pubdate As DateTime = DateTime.ParseExact(row.Cells(0).Text.ToString(), "yyyy-MM-dd", CultureInfo.InvariantCulture)
The above also probably applies to
Docdate and
format_Docdate where you need to check variable types and ensure the formating is correct.