.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 23rd, 2003, 04:16 PM
Watever Watever is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montreal, Canada
Posts: 486 Watever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 20 sec
Reputation Power: 6
Reading dataset with a datarow when Removing 2 item ? bug ?

I don't understand that. I am working on a fonction that is removing item in a BD that is not suppose to be there.

Everything look like is working find and the code look correct. But the bug happens when I remove 2 items in it and then try to continu to read with a datarow in the dataset.
It won't let me telling me that the line I am trying to access doesn't exist. How can it not exist ? I am going to the next one and I haven't deleted that one, IMO it's kinda stupid no ?

here is my code.
The problem is at the end of the code.

Code:
        'Déclare le DataSet des rues
        Dim dsDataSetRue As DataSet = frmItems.DataSetRue1.Copy
        'Déclare le DataSet des adresses
        Dim dsDataSetAdresse As DataSet = frmItems.DataSetAdresse1
        'Déclare le DataSet des villes
        Dim dsDataSetVille As DataSet = frmItems.DataSetVille1.Copy
        'Déclare une ligne dans la table des adresse
        Dim drDataRowAdresse As DataRow
        'Déclare une ligne dans la table des rues
        Dim drDataRowRue As DataRow
        'Déclare un objet pour la rue
        Dim objRue As Object
        'Déclare une variable pour savoir si élément trouvé
        Dim btrouve As Boolean = False
        'déclare un tableau qui aura les numéro de rue des rue du combobox
        Dim tabNoRue(cboRue.Items.Count) As Integer
        Dim i As Integer = 0
        'Declare un compteur pour savoir où on est ds la table
        Dim iIndex As Integer = 0


Code:
            iIndex = 0
            For Each drDataRowAdresse In dsDataSetAdresse.Tables("Adresse").Rows

                If drDataRowAdresse.Item("noreleve") = FindReleve(NoReleve) Then

                    'pour chaque element du tableau
                    For i = 1 To (tabNoRue.Length - 1)

                        'Si le numéro de la rue est correspondant a l'un des élément
                        If drDataRowAdresse.Item("norue") = tabNoRue(i) Then
                            btrouve = True
                            Exit For
                        End If

                    Next i

                    'Si l'élément n'est plus dans la liste
                    If btrouve = False Then
                        'Enlève de la DB la donnée se trouvant a l'iIndex
                        frmItems.BindingContext(frmItems.DataSetAdresse1, "Adresse").RemoveAt(iIndex)

                    Else : btrouve = False
                    End If

                End If

                'Ajoute 1 a l'index pour trouver l'élement où on est rendu
                iIndex = iIndex + 1

            Next
            'Force le programme a faire un update des données
            Try
                frmItems.OleDbDataAdapterAdresse.Update(frmItems.DataSetAdresse1)
            Catch
                MsgBox("Erreur pendant l'enregistrement des données de la table 'ADRESSE'.", MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, _
                                                                                                                    "Gestion des relevés")
            End Try
        Else
            'Affiche d'un message d'erreur s'il n'y a pas de rue d'ajouter
            MsgBox("Vous devez avoir au moins une rue pour chaque relevé", MsgBoxStyle.OKOnly, "Gestion des relevés")
        End If


    End Sub


I have put in bold the place where I remove the item. and the bug happens when it's hits the NEXT of the for.
I also tryed to make a database update but still won't work.

BTW : don't tell me the function is ugly and bad programming, I already know that. I am thinking of doing it all again but it would be long and I don't know how to really do it soo that if there is more then 1 user working on the database it's doesn't bug.
but I dope that I have other choice one of those days cause it's take to much time to do the function.
__________________

Reply With Quote
  #2  
Old September 24th, 2003, 10:20 AM
Watever Watever is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montreal, Canada
Posts: 486 Watever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 20 sec
Reputation Power: 6
nobody ever got something like that I should assume ?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Reading dataset with a datarow when Removing 2 item ? bug ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT