怎样利用dropdownlist insert DateTime 到access 中? ASP.NET C#
怎样利用dropdownlist insert DateTime 到access 中? ASP.NET C#以下的time应该错了的,但去除了TIME那一行跟P_TIME那个field 也是做不到只insert P_DATE
protected void Button1_Click1(object sender, EventArgs e)
{
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|ISE2001.accdb";
string cmdstr = "insert into Booking(PID,SID,P_DATE,P_Time) values(@PID,@SID,@P_DATE,@P_time)";
OleDbConnection con = new OleDbConnection(constr);
OleDbCommand com = new OleDbCommand(cmdstr, con);
int Y = Convert.ToInt32(Year.SelectedValue);
int M= Convert.ToInt32(Month.SelectedValue);
int D = Convert.ToInt32(Day.SelectedValue);
int Hr = Convert.ToInt32(Hour.SelectedValue);
int Mn = Convert.ToInt32(Min.SelectedValue);
DateTime thedate = new DateTime(Y,M,D);
DateTime time = new DateTime(Hr,Mn)
con.Open();
com.Parameters.AddWithValue("@PID", PID.Text);
com.Parameters.AddWithValue("@SID", SID);
com.Parameters.AddWithValue("@P_DATE",thedate)
com.Parameters.Add("@P_DATE", OleDbType.DBDate).Value = thedate;
com.Parameters.Add("@P_Time", OleDbType.DBTime).Value = time;
com.ExecuteNonQuery();
con.Close();
Literal1.Text = "Success Booking";
} C# ASP.NET --------------------编程问答--------------------
不明觉厉! --------------------编程问答-------------------- 应该解决了吧?
补充:.NET技术 , ASP.NET