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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:51:58+00:00 2026-05-14T16:51:58+00:00

I have to put data into a dictionary, thus formed: Dictionary (Of Integer, List

  • 0

I have to put data into a dictionary, thus formed: Dictionary (Of Integer, List (Of RicercaNews))

but when I go to put the list in the dictionary, I always return the same record, as if it does not increase the index of the list.

This is the code:

ResultTable Dim As New DataTable () 
            Dictgestionalews Dim As New Dictionary (Of Integer, List (Of RicercaNews)) 
            Listacat Dim As New Dictionary (Of Integer, String) 
            Dim listaricerca As List (Of RicercaNews) 
            Dim As New ricnews RicercaNews () 
            Try 
                listacat Me.GetAllCategoryNews = () 
                Dim comm As DbCommand = GenericDataAccess.CreateCommand () 


                For Each ck As KeyValuePair (Of Integer, String) In listacat 
                    comm.CommandText = "SELECT tabNews.idNews, tabNews.titolo, tabNews.commenti, tabNews.DataInizio, tabNews.DataFine, tabNews.idcatnews" _ 
                    & "FROM WHERE tabNews tabNews.idcatnews =" & ck.Key 
                    resultTable GenericDataAccess.ExecuteSelectCommand = (comm) 

                    If Me.GetFigliCategory (ck.Key)> 0 Then 
                        listaricerca = New List (Of RicercaNews) 

                        For index As Integer = 0 To resultTable.Rows (). Count () - 1 

                            ricnews.DataFine resultTable.Rows = (). Item (index). Item ("EndDate") 
                            ricnews.DataInizio resultTable.Rows = (). Item (index). Item ("StartDate") 
                            ricnews.idnews resultTable.Rows = (). Item (index). Item ("idNews) 
                            ricnews.titolo resultTable.Rows = (). Item (index). Item ("title") 
                            ricnews.idcatnews resultTable.Rows = (). Item (index). Item ("idcatnews) 
                            listaricerca.Add (ricnews) 
                        Next 



                        dictgestionalews.Add (ck.Key, listaricerca) 
                    Else 
                        dictgestionalews.Add (ck.Key New List (Of RicercaNews) ()) 

                    End If 

                Next 


                Return dictgestionalews 

            Catch ex As Exception 
                Utilita.LogError (former) 

                Return Nothing 
            End Try 
  • 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-14T16:51:59+00:00Added an answer on May 14, 2026 at 4:51 pm

    You need to reate a new instance of RicercaNews and store it in the variable ricnews on each iteration of your inner most loop. At present you’re creating just one instance and changing it’s properties on every iteration.

    Also, I can’t see what Me.GetFigliCategory(ck.Key) is doing but I suspect you don’t want to skip the object construction if it returns 0. Instead shouldn’t you create the new list if it returns 0 and then create the object and it to the list on every iteration, irresepective of whether Me.GetFigliCategory(ck.Key)` returned 0 or not?

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

Sidebar

Related Questions

Into some view data i have put the result of an anonymous type: var
We have a REST API which clients routinely POST and PUT data to. When
I have put together the following mootools script window.addEvent('domready', function() { var shouts =
I have put together a script which is very much like the flickr photostream
I have a Window where I have put a Frame. I would like to
In my project I have put all my css classes in the style sheets.
Greetings: I have put together a RESTful web service in .NET 3.5 that takes
I have a JLabel (actually, it is a JXLabel). I have put an icon
As part of a system I am working on we have put a layer
In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my

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.