我有 2 列,一列用于开始时间,另一列用于结束时间。它们都是那种类型nvarchar
,所以我可以比较它们。
我有一个文本框,它将接收用户的时间并自动回发以检查时间是否有效。
Dim compared_time_1 As DateTime
Dim compared_time_2 As DateTime
Dim select_time As SqlCommand
select_time = New SqlCommand("select Start_Time , End_Time from Clinic_Schedule where Schedule_no = @sch_no", appt_DB_1)
select_time.Parameters.AddWithValue("@sch_no", Sch_no)
Dim time_rdr As SqlDataReader
time_rdr = select_time.ExecuteReader()
While time_rdr.Read
compared_time_1 = DateTime.Parse(start_time_1)
compared_time_2 = DateTime.Parse(end_time_1)
start_time_1 = time_rdr(0).ToString
end_time_1 = time_rdr(1).ToString
If appt_time_txt0.Text >= start_time_1 And appt_time_txt0.Text <= end_time_1 Then
date_valid_lbl0.Visible = True
date_valid_lbl0.Text = "*Valid Time"
Else
time_valid_lbl0.Visible = True
time_valid_lbl0.Text = "*Not Valid Time"
End If
End While
time_rdr.Close()
我不知道我的逻辑是否有问题 XD。这些列中填写的数据采用以下格式:00:00AM or 00:00PM.
感谢您的帮助..谢谢