0
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";
        }

When i search i don't get any available rooms "No Rooms Availble" is what will come up, I have so many rooms available My intention is for user on search it will run through the datatable reservations, reservations.roomid compare it with the table Rooms rooms.roomid them show results of those items that are not find in the reservations but are in the rooms table to the Grid View.. thats all

thanks please help me out

2
  • The problem can be on the SQL statements. Did you run them against your database on the manager tool? Commented Jul 12, 2013 at 16:22
  • please give some more details about your problem.. Commented Jul 12, 2013 at 16:36

1 Answer 1

2

I think the first condition is wrong. The code should be

DataTable dt = try.Query("YOUR QUERY");
if (dt.Rows.Count > 0) {
   // Grid Bind Code
}
else {
   LblMessage.Text = " No Room Available";
}

Hope this will help !!

Sign up to request clarification or add additional context in comments.

3 Comments

I must be blind. Didn't notice that. Damn Fridays. LOL
Thanks i have tried it but it did not work.. what have in mind is for user on search it will run through the datable reservations, compare it with the table Rooms them show results of those items that are not find in the reservations but are in the rooms table to the Grid View.. Please help me out
@user1736648, i guess all the rooms exist in the ReservationTable because each room must be reserved sometime. So the problem is exist in the where condition, as you can see you didn't specify the date between criteria in second query. Try that and hopefully you will get rid out of this. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.