这是我的代码:
//Session["Date"]=ddlDate.SelectedItem+ ddlMonth.SelectedItem+ddlYear.SelectedItem;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
conn.Open();
string date = Convert.ToString(ddlYear.SelectedItem.Value) + "/" + Convert.ToString(ddlMonth.SelectedItem.Value) + "/" + Convert.ToString(ddlDate.SelectedItem.Value);
DateTime dt = Convert.ToDateTime(date);
// ddlYear.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + ddlDate.SelectedValue
SqlCommand cmd = new SqlCommand(@"insert into OnlineBookingEvent(BookingEvent,BookeventDate,cdt,udt)values
(@BookingEvent,@BookeventDate,@cdt,@udt)", conn);
cmd.Parameters.AddWithValue("@BookingEvent", ddlEventName.DataValueField);
cmd.Parameters.AddWithValue("@BookeventDate",dt);
cmd.Parameters.AddWithValue("@cdt", System.DateTime.Now);
cmd.Parameters.AddWithValue("@udt", System.DateTime.Now);
cmd.ExecuteNonQuery();