meds
meds

Reputation: 22916

DateTime in SQL Server CE query?

I have a date and time I'd like to insert into a SQL Server CE database, I'm trying to follow the string format yyyy-MM-dd hh:mm:ss but I get an invalid token exception when I try to insert it.

If the format is just dd-MM-yyyy everything is fine but I need to be able to add the time of day too...

Upvotes: 0

Views: 937

Answers (1)

Mayur Manani
Mayur Manani

Reputation: 825

It is always preferable to use Parameters:

cmd.Parameters.Add("@newTimeStamp", SqlDbType.DateTime).Value = timeStamp;

Upvotes: 2

Related Questions