I created a table and added a column as a DateTime.
I left the date to be inserted as a DateTime and made no conversions on it and it inserted.
Imports System
Imports DB_SqlLister ' keeps connection info
Imports System.Data.SqlClient
Module Module1
Sub Main()
Dim dateEnd As DateTime = DateTime.Now
Dim strSQL As String = "insert into XDB.XOWN.HAS_DATE (MY_DATE, COMMENT) values (@d, @s)"
Dim conn As New SqlConnection(CDB_SqlLister.csb.ToString())
conn.Open()
Dim cmd As New SqlCommand(strSQL, conn)
cmd.Parameters.Add("@d", SqlDbType.DateTime).Value = dateEnd
cmd.Parameters.Add("@s", SqlDbType.VarChar).Value = "DW_390905"
cmd.ExecuteNonQuery()
conn.Close()
End Sub
End Module
So, I would suggest converting your start and end dates to DateTime objects and everything will work (under the same conditions).
thines01
Postaholic
Team Colleague
2,425 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402