#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11

    What does this ERROR mean ?


    Une exception non gérée du type 'System.InvalidCastException' s'est produite dans Projet_DTI.exe

    Informations supplémentaires_: Le cast spécifié n'est pas valide.

    sorry I am working on a french station !
    If I translate it, it's mean

    An exception have not been managed (taked care of) of type 'System.InvalidCastException'

    Additionnal information : The specific cas is not valid.

    What does that mean ?

    here is the code where that happens
    Code:
                For Each objRue In cboRue.Items
                    i = i + 1
                    drDataRowRue = FindRue(objRue, nomVille, dsDataSetRue)
                    tabNoRue(i) = drDataRowRue.Item("norue")
                Next
    and the error happens on the third line (drdatarowrue =....)

    and here is what is findrue
    Code:
        Function FindRue(ByVal NomRue As String, ByVal NomVille As String, ByRef DataSetRue As DataSet) As _
                                                                                                    DataRow
            'Déclare une ligne dans la table des villes
            Dim drDataRowVille As DataRow
            'Déclare une ligne dans la table RUE
            Dim drDataRowRue As DataRow = Nothing
            'Déclare une ligne temporaire dans la table RUE
            Dim drDataRowRueTEMP As DataRow
            drDataRowVille = FindVille(NomVille, frmItems.DataSetVille1)
            If Not (drDataRowVille Is Nothing) Then
                For Each drDataRowRueTEMP In DataSetRue.Tables("Rue").Rows
                    If CStr(drDataRowRueTEMP.Item("rue")).ToUpper = NomRue.ToUpper And _
                            drDataRowRueTEMP.Item("noVille") = drDataRowVille.Item("noVille") Then
                        drDataRowRue = drDataRowRueTEMP
                        Exit For
                    End If
                Next
            End If
            Return drDataRowRue
        End Function
    Last edited by Watever; September 18th, 2003 at 03:45 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Windsor ON, Canada
    Posts
    462
    Rep Power
    14
    that's about the same error as a data type mismatch. it could be because objRue is an object (i assume) and you are passing it to a function that requries a string.

    try:
    Code:
    drDataRowRue = FindRue(CStr(objRue), nomVille, dsDataSetRue)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    I have found my stupid error. But wanted to tell you the error wasn't in the objRue, I checked it out. An string is an object so there is no error on it, it's just hierarchie.

    the error came from the third line.
    Code:
    For Each objRue In cboRue.Items
                    i = i + 1
                    drDataRowRue = FindRue(CStr(objRue), nomVille, dsDataSetRue)
                    [b]tabNoRue(i) = drDataRowRue.Item("norue")[/rue]
                Next
    that's where the error is part from. the real bug was created from different error, one of them was the table.
    Last edited by Watever; September 23rd, 2003 at 08:33 AM.

IMN logo majestic logo threadwatch logo seochat tools logo