Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4046044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:30:44+00:00 2026-05-20T13:30:44+00:00

I have a query using LINQ-to-SQL. It queries an underlying database table Rooms. It

  • 0

I have a query using LINQ-to-SQL. It queries an underlying database table Rooms. It uses Where conditions to narrow down the results, namely:

  1. Gender.
  2. Current Occupancy < Max Occupancy
  3. Available Flag is Checked

I know this should return results but it keeps returning an empty set. Any ideas? Code is below

    Dim selectedHalls = (From sh In dbHalls.Rooms _
                         Where sh.gender = Session("gender").ToString _
                         Where sh.max_occupancy > sh.current_occupancy _
                         Where sh.is_available = 1 _
                         Select sh.building_name).Distinct()

UPDATE: I’ve verified that the issue is with the statement where sh.is_available = 1, which doesn’t make sense since this is a bit field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:30:45+00:00Added an answer on May 20, 2026 at 1:30 pm

    I think the best way to find out what the problem is to generate the SQL string and test your assumption that “it should return results” by executing it directly against the data source.

    To do this:

          Dim sqlQuery As String =  dbHalls.GetCommand(
                        (From sh In dbHalls.Rooms _
                         Where sh.gender = Session("gender").ToString _
                         Where sh.max_occupancy > sh.current_occupancy _
                         Where sh.is_available = 1 _
                         Select sh.building_name).Distinct()
                  ).CommandText
    

    (I usually use C#, but I think that’s how you declare a string in VB, right?)

    Anyway, this will give you an SQL statement that will be more informative than anything we can give you without being able to look at your underlying database.

    The only thing that jumps out at me as being potentially problematic is the Session("gender"). You are basically relying on your Session object to be populated, have a value for the case-sensitive string key "gender" that matches the case-sensitive string field gender in your database. This sounds like quite a few assumptions, that may or may not be tested and could be the reason for receiving empty results.

    EDIT
    I just saw your update. Linq-to-sql, interprets a bit field as a boolean value, not an integer value. Try changing it to just where sh.is_available

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple table and I can happily query it using LINQ
I have a DataGridView that I want to query using Linq (C# WinForm). I
I have a problem with the following Linq query using Entity Framework: from o
I have a query in Delphi using DBExpress TSQLQuery that looks like so ActiveSQL.sql.add('SELECT
I am writing a searching function, and have thought up of this query using
I have a query that is currently using a correlated subquery to return the
I have a query that I am generating the XML from in Oracle using
So I have an SQL dump file that needs to be loaded using mysql_query().
I have been using the MySql Query Browser and [opinion]it has to be the
I'm using the content query web part and have exported it to a webpart

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.