Sending command with DateTime

  • Thread starter Thread starter Steffen Loringer
  • Start date Start date
S

Steffen Loringer

Hi,

I'm using SQLCmd = New SqlClient.SqlCommand and then
SQLCommand.CommandType = CommandType.Text

My problem is as follows: I like to update a table in SQL Server with a
column of the type DateTime.
so I used "UPDATE MyTable SET TheTime=" & ActualTime.ToString. But it's
not working. What is the way to send a DateTime datatype to SQL Server??

Thanks a lot

Steffen
 
1) Use parameter

sqlcmd.Parameters.Add([param name], sqldbtype.DateTime).Value = MyDate

2) Cast datetime to 'yyyyMMdd' format

"Update ... set TheTime = " & ActualTime.toString('yyyyMMdd')

HTH
 
Back
Top