添加此查询时出错:
OR (CONVERT(VARCHAR(8),CAST('" & start.SelectedValue & "' AS DATETIME),108) <= CONVERT(VARCHAR(8), [Time-in], 108) AND CONVERT(VARCHAR(8),CAST('" & ends.SelectedValue & "' AS DATETIME), 108) >= CONVERT(VARCHAR(8), [Time-out], 108)
这是整个查询:
Dim SQL5 = New SqlCommand("SELECT Room, CONVERT(VARCHAR(8), [Time-in], 108) AS [Time-in], CONVERT(VARCHAR(8), [Time-out], 108) as [Time-out] FROM [RS].[dbo].[Time] WHERE CAST([Reserve_date] AS DATE) = CAST('" & Calendar1.SelectedDate.ToString("yyyy-MM-dd") & "' AS DATE) AND Room = ('" & roomType.SelectedValue & "' ) AND (CONVERT(VARCHAR(8),CAST('" & start.SelectedValue & "' AS DATETIME),108) BETWEEN CONVERT(VARCHAR(8), [Time-in], 108) AND CONVERT(VARCHAR(8), [Time-out], 108) OR (CONVERT(VARCHAR(8),CAST('" & start.SelectedValue & "' AS DATETIME),108) <= CONVERT(VARCHAR(8), [Time-in], 108) AND CONVERT(VARCHAR(8),CAST('" & ends.SelectedValue & "' AS DATETIME), 108) >= CONVERT(VARCHAR(8), [Time-out], 108) OR CONVERT(VARCHAR(8),CAST('" & ends.SelectedValue & "' AS DATETIME), 108) BETWEEN CONVERT(VARCHAR(8), [Time-in], 108) AND CONVERT(VARCHAR(8), [Time-out], 108))", connection)