I have program that inserts data into SQL-server database
var format = "dd/MM/yyyy HH:mm:ss.mmm";   
date = DateTime.Now.ToString(format);
I have tried this one too : "yyyy-MM-dd HH:mm:ss.fff";
updateEvent_list = string.Format(@"INSERT INTO Events_List 
            (date, Object,Event,IOA,ASDU) 
            VALUES({0},{1},{2},{3},{4})", 
            date, event_object, "bla bla", ioa, ASDU);   
The date column type in the database is datetime2(7)
(0x80131904): Incorrect syntax near '10'
The date that was inserted : 12/07/2016 10:43:22.43
I have changed the date and it's always showing error near hours .
Execution code :
if (state == ConnectionState.Closed)   
   connection.Open();
try
{
    ExecuteQueryWithoutResult(connection, updateEvent_list);
    SetText2("update_Even_list query executed");
}
catch(Exception ex) { SetText2(ex.ToString()); }
static void ExecuteQueryWithoutResult(SqlConnection connection, string query)
{
    using (SqlCommand command = new SqlCommand(query, connection))
    {
        command.ExecuteNonQuery();
    }
}
NOTE : i tried to insert directly from sql query and it works fine :
INSERT INTO Events_List (date, Object,Event,IOA,ASDU)  
VALUES ('2016-07-12 10:26:03.523', 'B','bla bla' ,10,10)
 
     
     
    