Hi, I have to put data into a dictinary, 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
Can you tell me what's wrong? Thanks