DataTable dt = try.Query(" select Rooms.RoomId, Rooms.RoomType From Rooms INNER JOIN Reservations ON ( Rooms.RoomId = Reservations.RoomId ) AND GETDATE() BETWEEN Reservations.CheckInDate AND Reservations.CheckOutDate ORDER BY Rooms.RoomType");
if (dt.Rows.Count > 0)
{
LblMessage.Text = " No Room Available";
}
else
{
DataTable dt1 = try.Query( "Select Rooms.RoomType, Rooms.PricePerNight From Rooms INNER JOIN Reservations ON (Rooms.RoomId != Reservations.Roomid) ORDER BY Rooms.Roomtype");
if (dt1.Rows.Count > 0)
{
GridResult.DataSource = dt1;
GridResult.DataBind();
}
else
{
LblMessage.Text = "No Rooms Availble";
}
当我搜索我没有得到任何可用的房间“No Rooms Availble”将会出现,我有这么多房间可用 我的意图是用户搜索它将通过数据表预订,reservations.roomid将其与表格room.roomid进行比较它们显示在预订中找不到但在房间表格中的网格视图的项目的结果.. 多数民众赞成
谢谢,请帮帮我
答案 0 :(得分:2)
我认为第一个条件是错误的。代码应该是
DataTable dt = try.Query("YOUR QUERY");
if (dt.Rows.Count > 0) {
// Grid Bind Code
}
else {
LblMessage.Text = " No Room Available";
}
希望这会有所帮助!!