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

  • SEARCH
  • Home
  • 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 5976697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:15:55+00:00 2026-05-22T21:15:55+00:00

I have the following code that throws an error on the call for getOccupants

  • 0

I have the following code that throws an error on the call for getOccupants within Using dbPC. Is there a way to make this value accessible in Using dbPC? Or a better way to accomplish this? I tried nesting Using dbPC inside of Using dbContext, but that also throws errors.

  Protected Sub btnPushSemester_Click(sender As Object, e As EventArgs) Handles btnPushSemester.Click
    Dim dbPC As New Campus6Entities
    Dim dbContext As New pbu_housingEntities
    Using dbContext
        Dim get_Year = From p In dbContext.Configs _
                           Where p.Description = "year" _
                           Select p

        Dim get_Term = From p In dbContext.Configs _
                       Where p.Description = "term" _
                       Select p

        Dim thisYear = get_Year.First.textValue
        Dim thisTerm = get_Term.First.textValue
        Dim getOccupants = From p In dbContext.Residents _
                 Where p.semester = thisTerm _
                 Where p.year = thisYear _
                 Select p
    End Using
    Using dbPC
        For Each row In getOccupants
            Dim student_info = row
            Dim PCstudent = From r In dbPC.RESIDENCies _
                            Where student_info.people_code_id = r.PEOPLE_ID _
                            Where r.ACADEMIC_YEAR = thisYear _
                            Where r.ACADEMIC_TERM = thisTerm _
                            Select r

            For Each row2 In PCstudent
                Dim student_info2 = row2
                student_info2.DORM_BUILDING = student_info.Building1.building_code
                student_info2.DORM_ROOM = student_info.Room1.room1
                student_info2.RESIDENT_COMMUTER = "R"
                student_info2.DORM_CAMPUS = "O000000001"
                dbPC.SaveChanges()
            Next
        Next
    End Using

End Sub
  • 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-22T21:15:56+00:00Added an answer on May 22, 2026 at 9:15 pm

    Declare getOccupants outside of the using block. You can assign it inside the block, but you have to declare it outside or it goes out of scope before you actually need to use it.

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

Sidebar

Related Questions

I have the following code that won't compile and although there is a way
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
I have the following code that generates a compiler error: Boolean IConvertible.ToBoolean(IFormatProvider provider) {
I have following code that does not work due to a being a value
I have following code snippet that i use to compile class at the run
I have the following code that shows either a bug or a misunderstanding on
I have the following code that creates two objects (ProfileManager and EmployerManager) where the
I have the following code that I need to add an additonal object to
I have the following code that creates a serverside object of the xmlhttp class.
I have the following code that loads a user's Active Directory DirectoryEntry object from

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.