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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:12:49+00:00 2026-06-16T05:12:49+00:00

Hi i have the following function: Public Shared Function GetAbrechnung() As List(Of WochenBPlan) Dim

  • 0

Hi i have the following function:

    Public Shared Function GetAbrechnung() As List(Of WochenBPlan)


        Dim wbp = New WochenBPlan
        Dim allBookings As List(Of WochenBPlan) = New List(Of WochenBPlan)

        Dim strSQL As String = "SELECT DISTINCT d.ABTEILUNG, d.BEMERKUNG, d.BESTUHLUNG, d.RAUMID, d.ID, d.PERSONENZAHL, d.ADRESSE + ', ' + d.RAUMBEZEICHNUNG AS RAUMBEZEICHNUNG, d.THEMA, p.VN + ' ' + p.NN AS NAME, CONVERT (char(5), d.VON, 108) + ' - ' + CONVERT (char(5), d.BIS, 108) AS ZEIT, p.TEL FROM VIEW_RAUMBUCHUNG_DISPO AS d INNER JOIN PERSONAL AS p ON d.PERSONAL_ID = p.ID WHERE THEMA = 'EVENT'"
        Dim objRS As SqlDataReader

        objRS = SQLrunReaderWB(strSQL)
        If objRS.HasRows Then

            While objRS.Read()

                wbp.Raum = objRS("RAUMBEZEICHNUNG")
                wbp.Zeit = objRS("ZEIT")

                If Not IsDBNull(objRS("ABTEILUNG")) Then
                    wbp.Bereich = objRS("ABTEILUNG")
                End If

                If Not IsDBNull(objRS("THEMA")) Then
                    wbp.Thema = objRS("THEMA")
                End If

                If Not IsDBNull(objRS("NAME")) Then
                    wbp.Mieter = objRS("NAME")
                End If

                If Not IsDBNull(objRS("TEL")) Then
                    wbp.Mieter_Tel = objRS("TEL")
                End If

                wbp.Personen = objRS("PERSONENZAHL")
                wbp.Bestuhlung = objRS("BESTUHLUNG")

                If Not IsDBNull(objRS("BEMERKUNG")) Then
                    wbp.Bemerkung = objRS("BEMERKUNG")
                End If



                allBookings.Add(wbp)


            End While


        Else

        End If

        ConnWB.Close()
        Return allBookings

End Function

My Problem is that my List which i have generated is just returning the last value. What iam doing wrong? Can someone help?

  • 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-06-16T05:12:50+00:00Added an answer on June 16, 2026 at 5:12 am

    You need to declare your scope object inside the loop. If you do not, you will get only the reference of the same object, changing it and therefore will be the last modification that will contain the list.

    try something like this:

    Public Shared Function GetAbrechnung() As List(Of WochenBPlan)
    
            Dim allBookings As List(Of WochenBPlan) = New List(Of WochenBPlan)
    
            Dim strSQL As String = "SELECT DISTINCT d.ABTEILUNG, d.BEMERKUNG, d.BESTUHLUNG, d.RAUMID, d.ID, d.PERSONENZAHL, d.ADRESSE + ', ' + d.RAUMBEZEICHNUNG AS RAUMBEZEICHNUNG, d.THEMA, p.VN + ' ' + p.NN AS NAME, CONVERT (char(5), d.VON, 108) + ' - ' + CONVERT (char(5), d.BIS, 108) AS ZEIT, p.TEL FROM VIEW_RAUMBUCHUNG_DISPO AS d INNER JOIN PERSONAL AS p ON d.PERSONAL_ID = p.ID WHERE THEMA = 'EVENT'"
            Dim objRS As SqlDataReader
    
            objRS = SQLrunReaderWB(strSQL)
            If objRS.HasRows Then
    
                While objRS.Read()
    
                    'declare here a new instance to add on the list
                    Dim wbp = New WochenBPlan
    
                    wbp.Raum = objRS("RAUMBEZEICHNUNG")
                    wbp.Zeit = objRS("ZEIT")
    
                    If Not IsDBNull(objRS("ABTEILUNG")) Then
                        wbp.Bereich = objRS("ABTEILUNG")
                    End If
    
                    If Not IsDBNull(objRS("THEMA")) Then
                        wbp.Thema = objRS("THEMA")
                    End If
    
                    If Not IsDBNull(objRS("NAME")) Then
                        wbp.Mieter = objRS("NAME")
                    End If
    
                    If Not IsDBNull(objRS("TEL")) Then
                        wbp.Mieter_Tel = objRS("TEL")
                    End If
    
                    wbp.Personen = objRS("PERSONENZAHL")
                    wbp.Bestuhlung = objRS("BESTUHLUNG")
    
                    If Not IsDBNull(objRS("BEMERKUNG")) Then
                        wbp.Bemerkung = objRS("BEMERKUNG")
                    End If
    
    
                    ' add the reference to the new object on the list
                    allBookings.Add(wbp)    
    
                End While    
    
            'Else ---> you do not need this ELSE scope, just remove it
    
            End If
    
            ConnWB.Close()
    
            Return allBookings
    
    End Function
    
    • 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: Public Shared Function DPLoadData() As String Dim s As
I have the following code: Public Shared Function GetListAsString(ByVal data As List(Of String)) As
I have the following code: Public Shared Function GetAvailableManufacturers() As List(Of Manufacturer) 'first get
I have the following function for SQLite select statement public Boolean itemFound(String cartId,Long ItemId){
If have the following Code: Public Shared Function GetNextWeekDay() As Date Dim value As
I have the following function: public static byte[] StringToByte(string str) { int length =
I have following repository: public function findClassPhotoByPath($path) { return $this->getEntityManager() ->createQuery('SELECT p FROM KSRGalleryBundle:Photo
I have the following method written in VB .Net: <ExcelFunction(Description:=Test, HelpTopic:=http://www.google.co.za)> Public Shared Function
We have a VB.net function with the following signature in class InitializerFactory: Public Shared
I have an ASP.NET PageMethod with the following signature: <WebMethod()> _ Public Shared Function

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.