I can only find out how to get current date, not the combination of current date and time. I haven't found any fitting solution.
cmd.CommandText = "INSERT INTO [Table] (DATE) VALUES (@date)";
var pDate = new OleDbParameter("@date", SqlDbType.DateTimeOffset);
pDate.Value = DateTime.Now.Date;
var dateAndTime = DateTime.Now;
var date = dateAndTime.Date;
Access SQL supports a function named
Now() which returns the current date and time.
So it would be simpler to let the db engine use
Now() instead of deriving the equivalent value in c# and then feeding that value to your
INSERT as a parameter.
cmd.CommandText = "INSERT INTO [Table] ([DATE]) VALUES (Now())";
Date is a Jet reserved word. Enclose that name in square brackets in the
INSERT to signal the db engine you mean an object name instead of the