Sending command with DateTime

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
 
A

Anatoly

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top