I have a database field of dateTime, I'm added a DateTimePicker Control into the window , I want that if not selected any date. Not enter anything into the database I tried the following code And it returns an error ,Does anyone have an idea? I am working on WPF, C # and Access DB
try
{
string insert_query = "INSERT INTO dbo_tasks ( Date_Created, write_From, Task_To ) " +
"VALUES ('" + DP_date.SelectedDate + "', " + txt_from.SelectedValue + ", " + txt_to.SelectedValue + ")";
con1.Open();
OleDbCommand cmd = new OleDbCommand(insert_query, con1);
cmd.ExecuteNonQuery();
}
catch (Exception)
{
MessageBox.Show("");
}
con1.Close();