Forum :: .NET :: ขอคำแนะนำหรือตัวอย่าง การทำให้ข้อมูลเวลาที่ลง มันตรงกับวันที่ ที่กำหนดไว้หน่อยครับ

-
Little Baphomet
- Badge 0 Following 1 Follower 0 Reference 1 Forum 0 Application 0 Book 0 Comment
- About Me
- เมื่อ 27 พฤษภาคม 2015 เวลา 20 นาฬิกา 49 นาที
- 584 Read
- 0 Comment
- 0 Like
- 0 Follower
คือผมต้องการ ให้ วันที่ ที่ลงในช่องเวลาเข้าเรียน ให้มันลงตรงกับช่อง เวลาเริ่มเรียน อย่างเช่น ผมลงไปวันที่ 2015-05-27 17:25:54 อยากให้มันลงแค่ในช่องที่วันที่ตรงกับ 2015-05-27 08:00:00 แต่ตอนผมรันโปรแกรม มันลงไปในช่องเวลาทุกวันเลย อยากทราบว่าต้องแก้ หรือเพิ่มเติมอะไรเข้าไปมั่งครับ อันนี้ใน database ครับ เวลาเริ่มเรียน คือ start_time ส่วนเวลาที่เข้าเรียน คือ chktime [img]http://www.img.in.th/images/MfS7.jpg[/img] อันนี้โคดในโปรแกรม visual ที่นำเวลาไปลงในฐานข้อมูลครับ MySqlConnection objConn = new MySqlConnection(); MySqlCommand objCmd = new MySqlCommand(); string strConnString = null; string strSQL = null; string strSQL1 = null; DateTime cutime = DateTime.Now; strConnString = "Server=localhost;User Id=root; Password=123456789; Database=mydatabase; Pooling=false"; objConn.ConnectionString = strConnString; objConn.Open(); int intNumRows = 0; if (this.label4.Text != "") { strSQL1 = "SELECT * FROM tabletime WHERE UserID = '" + this.label4.Text.Trim() + "' AND no_vicha = '" + this.textBox2.Text + "' AND Status = 1"; objCmd = new MySqlCommand(strSQL1, objConn); intNumRows = Convert.ToInt32(objCmd.ExecuteScalar()); if (intNumRows > 0) { strSQL = "UPDATE tabletime SET chktime = '" + String.Format("{0:u}", DateTime.Now) + "',Status = 2 WHERE UserID = '" + this.label4.Text.Trim() + "' AND no_vicha = '" + this.textBox2.Text.Trim() + "'"; objCmd.Connection = objConn; objCmd.CommandText = strSQL; objCmd.CommandType = CommandType.Text;
0 Comment
- Have no comment.