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 167873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:21:10+00:00 2026-05-11T12:21:10+00:00

may someone could help me on one problem in query LINQ to SQL Visual

  • 0

may someone could help me on one problem in query LINQ to SQL Visual Basic.

My database has three tables,

* Students(StudentID, StudentName), * Class(ClassID, ClassDate), * Attendance(StudentID, ClassID) which Attendance tables is the junction table between Students and Class. 

For example:

Students

StudentsID………….StudentName

1001………………….Smith

1002………………….John

1003………………….Bob

Class

ClassID…………ClassDate

1………………….1/1/2009

2………………….1/3/2009

3 …………………1/7/2009

Attendance

StudentID…………ClassID

1001 ……………….1

1002 ……………….1

1003 ……………….1

1001 ……………….2

1003 ……………….2

1001 ……………….3

1002 ……………….3

1003 ……………….3

I have try the query Visual Basic LINQ to SQL below to list all the student and the count number of attendance in a range of date.

1 Dim db = New AttendanceControllerDataContext 2 3 Dim result = From std In db.Students _ 4 Select std.StudentID, _ 5 std.StudentName, _ 6 Attendance = std.Attendances.Count() 7 8 GridView1.DataSource = result 9 GridView1.DataBind() 

When I try this, it gives me:

StudentID……..StudentName…..Attendance

1001……………Smith…………………3

1002……………John………………….2

1003……………Bob…………………..3

In line 6, Attendance I want to count according to the range of date in the Class Table, For example if I selected a range of date between 1/2/2009 and 1/7/2009, then I have tried the following code:

 1   Dim db = AttendanceControllerDataContext   2   Dim result = From std In db.Students, atd In db.Attendances _  3                Where atd.studentID = std.studentID _  4                Select std.studentID, _  5                std.studentName, _  6                Attendance = atd.Class.date >= 1/2/2009 _  7                And atd.Class.date <= 1/7/2009  std.Attendances.Count()  8   GridView1.DataSource = result  9   GridView1.DataBind() 

The result is:

StudentID……..StudentName…..Attendance

1001……………Smith…………………2

1001……………Smith…………………2

1002……………John………………….1

1003……………Bob…………………..2

1003……………Bob…………………..2

However, I just wanted a list that look like below only:

StudentID……..StudentName…..Attendance

1001……………Smith…………………2

1002……………John………………….1

1003……………Bob…………………..2

How can I do this? Any suggestion? Thank in advance..

  • 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. 2026-05-11T12:21:11+00:00Added an answer on May 11, 2026 at 12:21 pm

    Instead of

    Attendance = std.Attendances.Count() 

    in your first code sample use

    Attendance = std.Attendances.Where(Function(att) att.Class.ClassDate >= '1/2/2009' And att.Class.ClassDate <= '1/7/2009').Count() 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 155k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Pass 0 as the port number to the IPEndPoint constructor:… May 12, 2026 at 10:39 am
  • Editorial Team
    Editorial Team added an answer Charles is just a web proxy, so it won't throttle… May 12, 2026 at 10:39 am
  • Editorial Team
    Editorial Team added an answer Final Conclusion is it's a bug see bottom I tried… May 12, 2026 at 10:39 am

Related Questions

I have a daemon that reads a configuration file in order to know where
Ok, so I'll try to be as descriptive as possible. I'm working on a
I recently asked a question about functional programming, and received (good!) answers that prompted
I hope someone could help me on this. I want to add a month

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.