I am using EF6 with SQL Server/SQL Azure with C# and MVC5
I am trying to do something like:
string insertFeatureCmd = String.Format("INSERT INTO TABLE (Name,Value, DateActivated) " + "VALUES ('{0}','{1}','{2}')", name,value, DateTime.Now);
db.ExecuteStoreCommand(insertFeatureCmd);
What is the correct syntax for handling the Date Value? Is it '{2}' or {2}. Also do I need to do something with DateTime.Now ie DateTime.Now.ToString() or "DateTime.Now.ToLongDateString()" or something?
Thanks.
EDIT
I get the following SQL generated from my C#. Question is what to do with that data value?
INSERT INTO TABLE (Name,Value,DateActivated) VALUES ('Name','Value',07/04/2019 02:39:24)
EDIT2
This does not work. I get an exception:
INSERT INTO TABLE (Name,Value,DateActivated) VALUES ('Name','Value','07/04/2019 02:39:24')
EDIT3: In response to suggested alternative answer. My solution that I went with was, inspired by link, but was:
new SqlParameter("@sinceDateTime", myDate)