Reputation: 22916
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
Reputation: 825
It is always preferable to use Parameters:
cmd.Parameters.Add("@newTimeStamp", SqlDbType.DateTime).Value = timeStamp;
Upvotes: 2