string Tin = DropDownList2.Text;
string Tout = DropDownList3.Text;
"SELECT COUNT(*) FROM schedule where timein between ('" + Tin + "') and ('" +Tout + "') or timeout between ('" +Tin + "') and ('" +Tout+"') ";
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[spChkroomForAdd]
@Room varchar(10),
@Starttime datetime,
@Endtime datetime
AS
BEGIN
SET NOCOUNT ON;
SELECT room, starttime, endtime,reserve_by
FROM reservati0n
WHERE (ROOM=@ROOM AND (CONVERT(VARCHAR(19),@Starttime,120) BETWEEN starttime AND endtime OR
CONVERT(VARCHAR(19),@Endtime,120) BETWEEN starttime AND endtime ))
OR (ROOM=@ROOM AND @Endtime > endtime AND @Starttime < starttime)
END
sql = "SELECT COUNT(*) FROM dataschedule1 where date ='" + textBox1.Text+ "' and '" + DropDownList2.SelectedValue + "' between timein and timeout or '" + DropDownList3.SelectedValue + "' between timein and timeout and '" + DropDownList3.SelectedValue + "'))";
*dropdownlistDay >> ddlDay มี (mon,tue,...,fri)
ddltimein.SelectedValue , ddltimeout.SelectedValue >> dropdownlist ค่าเวลา 08:01 AM , 08:30 AM , ..... อะไรก็ว่าไป
Code
SELECT * FROM dataschedule1
WHERE (Day='ddlDay.SelectedValue' AND (CONVERT(VARCHAR(19),ddltimein.SelectedValue ,108) BETWEEN timein AND timeout OR
CONVERT(VARCHAR(19),ddltimeout.SelectedValue ,108) BETWEEN timein AND timeout ))
OR (Day=ddlDay.SelectedValue AND ddltimeout.SelectedValue > timeout AND ddltimein.SelectedValue < timein)