var s = (from x in ent.Flights select x).FirstOrDefault(); dateTimePicker1.Value = s.FlightDate;
String connectionString = @"Your connection string"; SqlConnection thisConnection = new SqlConnection(connectionString); try { thisConnection.Open(); String thisQuery = "INSERT INTO ProjectList (Date) VALUES ('"+dtpDate.Value.Date+"')"; SqlCommand thisCommand = new SqlCommand(thisQuery, thisConnection); thisCommand.ExecuteNonQuery(); thisConnection.Close(); } catch (SqlException e) { Console.WriteLine(e.Message); }
using (SqlConnection con = new SqlConnection(strConnect)) { con.Open(); using (SqlCommand com = new SqlCommand("INSERT INTO myTable (myDate) VALUES (@DATE)", con)) { com.Parameters.AddWithValue("@DATE", myDateTimePicker.Value); com.ExecuteNonQuery(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)