I have tried using a DateTimePicker
with format dd/MM/yyyy
to insert a date into a Date/Time
column in my MS Access database using the insert SQL statement.
Here is what I have done:
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection; // Connecting the command to the connection.
command.CommandText = "insert into [TestEntry] (TestTableID, StudentID, DateOfTest, [DeadLine]) values(" + int.Parse(txtTestName.Text) + ", " + int.Parse(studentID) + ", #" + this.dateTimeStartD.Text + "# , #" + this.dateTimeEndD.Text + "#)";
command.ExecuteNonQuery();
connection.Close();
I keep getting the error
Input string was not in correct format
The Date/Time columns in my Access table are formatted as 'Short date' eg. 12/11/2015.
Any help will be appreciated.