Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1176
wingrid error when loading data
posted

 i have this procedure that fill my wingrid but i have an intermitent problem, if i ran my process 30 times only 2 or 3 times will throw the following error, any idea on what is wrong with my code or is a wingrid problem?

Error

not alway same error, but intermitent, all of them had results the store procedure

1)   ************** Exception Text **************
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

2) ************** Exception Text **************
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Code

 Private Sub LoadResults(ByVal StrFromDate As String, ByVal StrPercentage As String)
        Dim DS As DataSet = New DataSet

        Try
            QueryHst = False
            DS.Tables.Clear()
            Application.DoEvents()

            DS.Tables.Add(Conn.GetData("exec sp_DataGetPriceError " & _
                                    "@FromDate = '" + StrFromDate + "', " & _
                                    "@Percentage = " + IIf(StrPercentage = 100, "1.0", "0." + Format(CInt(StrPercentage), "00").ToString)))

            'Show the grid
            dgv1.ResetLayouts()
            dgv1.SetDataBinding(DS, "table1")

            ShowAnimation(False)

        Catch Ex As Exception

            Conn.LogError(gUser.pUserID.ToString, My.Computer.Name.ToString, "Frm Price Error", "Load Results", "value change", "1", Ex.Message.ToString)
        End Try

    End Sub

store procedure always return a value.

Image