Avatar billede agerled Nybegynder
08. februar 2005 - 07:55 Der er 1 kommentar og
1 løsning

Får fejl jeg ikke forstår

Jeg får denne fejl:

An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll

Additional information: Samlingen er blevet ændret. Optællingen bliver muligvis ikke udført.


Her min kode som udføres hvert 45. sekund via en timer.


  Private Sub FillHitrateIdag()

        Dim cnSQL As OracleConnection
        Dim cmSQL As OracleCommand
        Dim drSQL As OracleDataReader
        Dim strSQL As String
        Dim strID As String

        Try

            strSQL = "select * from hitrate_dk where dato = '" & HitSelDate & "' and navn <> 'Total' order by hitrate DESC"
            cnSQL = New OracleConnection(Util.DBConn())
            cnSQL.Open()
            cmSQL = New OracleCommand(strSQL, cnSQL)
            drSQL = cmSQL.ExecuteReader()


            lstHitrate.ImageList = Util.ListViewIcons

            lstHitrate.Columns.Clear()
            lstHitrate.Items.Clear()



            'This sets the columns of the ListView to the same column names of the table in the database
            With lstHitrate
                .Columns.Add(("Navn"), 65, ContentAlignment.MiddleLeft)
                .Columns.Add(("SK"), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("SL"), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("ØK"), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("ØL"), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("Prod."), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("SA"), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("Fors."), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("MA"), 35, ContentAlignment.MiddleRight)
                .Columns.Add(("MA Hit%"), 70, ContentAlignment.MiddleRight)
                .Columns.Add(("RealHit%."), 70, ContentAlignment.MiddleRight)
                .Columns.Add(("Hit%."), 70, ContentAlignment.MiddleRight)
                .Columns.Add(("P. Idag"), 50, ContentAlignment.MiddleRight)
                .Columns.Add(("Prod. Gns."), 65, ContentAlignment.MiddleRight)
                .Columns.Add(("P. Total"), 50, ContentAlignment.MiddleRight)
                .Columns.Add(("Ready%"), 60, ContentAlignment.MiddleRight)
                .Columns.Add(("Besvarelses%"), 80, ContentAlignment.MiddleRight)
                .Columns.Add(("Ready saldo"), 75, ContentAlignment.MiddleRight)

            End With



            Dim item As New GlacialComponents.Controls.GLItem

            'Now scrolling through the DataReader and populating the ListView with the data
            If drSQL.Read() Then
                While drSQL.Read()

                    item = lstHitrate.Items.Add(drSQL.Item("navn").ToString())
                    item.SubItems(0).ImageIndex = 0
                    item.SubItems(1).Text = drSQL.Item("kald").ToString()
                    item.SubItems(2).Text = drSQL.Item("listen").ToString()
                    item.SubItems(3).Text = drSQL.Item("kaldikkesalg").ToString()
                    item.SubItems(4).Text = drSQL.Item("listeikkesalg").ToString()
                    item.SubItems(5).Text = drSQL.Item("produkter").ToString()
                    item.SubItems(6).Text = drSQL.Item("servabon").ToString()
                    item.SubItems(7).Text = drSQL.Item("forsabon").ToString()
                    item.SubItems(8).Text = drSQL.Item("teleabon").ToString()

                    If drSQL.Item("kald") > 0 Or drSQL.Item("listen") > 0 Then
                        Dim maprocent As Integer = (drSQL.Item("teleabon") / (drSQL.Item("kald") + drSQL.Item("listen"))) * 100

                        item.SubItems(9).Text = FormatNumber(maprocent, 1).ToString() & "%"
                        item.SubItems(9).ImageIndex = HitrateColor.MAColorDK(maprocent, "BG")

                    Else

                        item.SubItems(9).Text = "0,0%"
                        item.SubItems(9).ImageIndex = 8

                    End If


                    If drSQL.Item("realhit").ToString() <> "" Then


                        If drSQL.Item("realhit") > 0 Then
                            item.SubItems(10).Text = FormatNumber(drSQL.Item("realhit"), 1).ToString() & "%"
                            item.SubItems(10).ImageIndex = HitrateColor.RealHitColorDK(drSQL.Item("realhit"), "BG")

                        Else

                            item.SubItems(10).Text = FormatNumber(drSQL.Item("realhit"), 1).ToString() & "%"
                            item.SubItems(10).ImageIndex = 8
                        End If

                    Else
                        item.SubItems(10).Text = ""
                    End If

                    If drSQL.Item("hitrate") > 0 Then

                        item.SubItems(11).Text = FormatNumber(drSQL.Item("hitrate"), 1).ToString() & "%"
                        item.SubItems(11).ImageIndex = HitrateColor.HitrateColorDK(drSQL.Item("hitrate"), "BG")

                    Else

                        item.SubItems(11).Text = FormatNumber(drSQL.Item("hitrate"), 1).ToString() & "%"
                        item.SubItems(11).ImageIndex = 8

                    End If

                    item.SubItems(12).Text = drSQL.Item("points").ToString()
                    item.SubItems(13).Text = FormatNumber(drSQL.Item("AVGPRODUKTPOINT"), 1).ToString()
                    item.SubItems(14).Text = drSQL.Item("totalpoints").ToString()

                    item.SubItems(15).Text = FormatNumber(drSQL.Item("readyprocent"), 0).ToString() & "%"
                    item.SubItems(15).ImageIndex = HitrateColor.ReadyProcentColorDK(drSQL.Item("readyprocent"), "BG")


                    item.SubItems(16).Text = FormatNumber(drSQL.Item("besvarelse"), 0).ToString() & "%"
                    item.SubItems(16).ImageIndex = HitrateColor.BesvarelsesProcentColorDK(drSQL.Item("besvarelse"), "BG")


                    item.SubItems(17).Text = drSQL.Item("readysaldo").ToString()
                    item.SubItems(17).ImageIndex = HitrateColor.ReadySaldoColorDK(drSQL.Item("readysaldo"), "BG")


                    If drSQL.Item("navn") = UserInfo.UserName Then
                        item.BackColor = Color.LightGray

                    End If

                End While



                ' Close and Clean up objects
                cnSQL.Close()
                cmSQL.Dispose()
                cnSQL.Dispose()



                strSQL = "select * from hitrate_dk where dato = '" & HitSelDate & "' and navn = 'Total'"
                cnSQL = New OracleConnection(Util.DBConn())
                cnSQL.Open()
                cmSQL = New OracleCommand(strSQL, cnSQL)
                drSQL = cmSQL.ExecuteReader()

                If drSQL.Read() Then


                    item = lstHitrate.Items.Add(drSQL.Item("navn").ToString().ToUpper)
                    item.SubItems(0).ImageIndex = 10
                    item.SubItems(1).Text = drSQL.Item("kald").ToString()
                    item.SubItems(2).Text = drSQL.Item("listen").ToString()
                    item.SubItems(3).Text = drSQL.Item("kaldikkesalg").ToString()
                    item.SubItems(4).Text = drSQL.Item("listeikkesalg").ToString()
                    item.SubItems(5).Text = drSQL.Item("produkter").ToString()
                    item.SubItems(6).Text = drSQL.Item("servabon").ToString()
                    item.SubItems(7).Text = drSQL.Item("forsabon").ToString()
                    item.SubItems(8).Text = drSQL.Item("teleabon").ToString()

                    If drSQL.Item("kald") > 0 Or drSQL.Item("listen") > 0 Then
                        Dim maprocent As Integer = (drSQL.Item("teleabon") / (drSQL.Item("kald") + drSQL.Item("listen"))) * 100

                        item.SubItems(9).Text = FormatNumber(maprocent, 1).ToString() & "%"
                        item.SubItems(9).ImageIndex = HitrateColor.MAColorDK(maprocent, "BG")

                    Else

                        item.SubItems(9).Text = "0,0%"
                        item.SubItems(9).ImageIndex = 8

                    End If


                    If drSQL.Item("realhit").ToString() <> "" Then


                        If drSQL.Item("realhit") > 0 Then
                            item.SubItems(10).Text = FormatNumber(drSQL.Item("realhit"), 1).ToString() & "%"
                            item.SubItems(10).ImageIndex = HitrateColor.RealHitColorDK(drSQL.Item("realhit"), "BG")

                        Else

                            item.SubItems(10).Text = FormatNumber(drSQL.Item("realhit"), 1).ToString() & "%"
                            item.SubItems(10).ImageIndex = 8
                        End If

                    Else
                        item.SubItems(10).Text = ""
                    End If



                    If drSQL.Item("hitrate") > 0 Then

                        item.SubItems(11).Text = FormatNumber(drSQL.Item("hitrate"), 1).ToString() & "%"
                        item.SubItems(11).ImageIndex = HitrateColor.HitrateColorDK(drSQL.Item("hitrate"), "BG")

                    Else

                        item.SubItems(11).Text = FormatNumber(drSQL.Item("hitrate"), 1).ToString() & "%"
                        item.SubItems(11).ImageIndex = 8

                    End If


                    item.SubItems(12).Text = drSQL.Item("points").ToString()
                    item.SubItems(13).Text = FormatNumber(drSQL.Item("AVGPRODUKTPOINT"), 1).ToString()
                    item.SubItems(14).Text = drSQL.Item("totalpoints").ToString()

                    item.SubItems(15).Text = FormatNumber(drSQL.Item("readyprocent"), 0).ToString() & "%"
                    item.SubItems(15).ImageIndex = HitrateColor.ReadyProcentColorDK(drSQL.Item("readyprocent"), "BG")


                    item.SubItems(16).Text = FormatNumber(drSQL.Item("besvarelse"), 0).ToString() & "%"
                    item.SubItems(16).ImageIndex = HitrateColor.BesvarelsesProcentColorDK(drSQL.Item("besvarelse"), "BG")


                    item.SubItems(17).Text = drSQL.Item("readysaldo").ToString()
                    item.SubItems(17).ImageIndex = HitrateColor.ReadySaldoColorDK(drSQL.Item("readysaldo"), "BG")


                End If

                lblHitTidspunkt.Text = "Kl. " & drSQL.Item("lastupdate")

            Else
                lstHitrate.Columns.Clear()
                lstHitrate.Columns.Add(("Info"), 200, ContentAlignment.MiddleLeft)
                lblHitTidspunkt.Text = ""
                item = lstHitrate.Items.Add("De første tal er klar kl. 08:00")

            End If

            ' Close and Clean up objects
            cnSQL.Close()
            cmSQL.Dispose()
            cnSQL.Dispose()

        Catch Exp As OracleException
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "Oracle Error")

        Catch Exp As Exception
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
        End Try




    End Sub
Avatar billede agerled Nybegynder
08. februar 2005 - 07:56 #1
Det er dog ikke altid at fejlen kommer..... Nogle gange går der op til flere timer før fejlen kommer...
Avatar billede agerled Nybegynder
10. februar 2005 - 10:00 #2
Har fundet problemet. Det var min timer den var gal med.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester