开发者

ARRGH! Duplicate results in from a query, but only sometimes

ARRGH! Duplicate results in from a query, but only sometimes

UPDATE>>>> If I run this on localhost, their is no duplication of data, but on the site there is. Does that help to give people an idea of what may be going on?

I have an application built by someone else that is returning results from a socket call when the end user types in a little product info, and hits submit. The application returns the results, but it sometimes displays the results twice. For example, if I click submit on the application to do a search for a product, it may come back with the correct one, two, or three records (as there could be results from 1-3 locations), or it may repeat all those results twice. (Ie.: if there were two records returned, it might simply display the info from the two records, or it may display the results from the two records in the first two rows of the , and then repeat rows 1 & 2 in rows 3 & 4.) Continuing to click submit on that page will (it appears randomly) change the resulting displayed data - cycling between one set of results and two.

Any ideas on what may be causing this? I've included the bit of code I think is involved. I inherited this code, and am trying to make it work, but I'm new to this type of application and only intermediate at best in asp.net. Thank-you in advance to anyone who can shed some light!!

Protected Sub displayTableOne(ByVal records() As String)

    Dim dt As New DataTable()
    Dim values() As String = {""}
    Dim i As Integer = 0

    Try

        Dim Row() As String = {"Company", "Piece", "Description", _
        "Location", "Available", "Purchased", "Ship Date"}

        #Create the columns
        Dim column1 As New DataColumn("Company", GetType(String))
        Dim column2 As New DataColumn("Piece", GetType(String))
        Dim column3 As New DataColumn("Description", GetType(String))
        Dim column4 As New DataColumn("Location", GetType(String))
        Dim column5 As New DataColumn("Available", GetType(String))
        Dim column6 As New DataColumn("Purchased", GetType(String))
        Dim column7 As New DataColumn("Ship Date", GetType(String))


        dt.Columns.Add(column1)
        dt.Columns.Add(column2)
        dt.Columns.Add(column3)
        dt.Columns.Add(column4)
        dt.Columns.Add(column5)
        dt.Columns.Add(column6)
        dt.Columns.Add(column7)


        If (records.Length > 1) Then
            For i = 0 To records.Length - 2 Step 1

                values = Split(records(i), "|")
                Dim l As Integer = 0
                Dim dr As DataRow
                dr = dt.NewRow()

                If values(0) = "05" Then

                    If (values.Length > 4) Then
                        dr(Row(0)) = values(1)
                        dr(Row(1)) = values(2)
                        dr(Row(2)) = values(13)
                        dr(Row(3)) = values(17)
                        dr(Row(4)) = values(7)
                        dr(Row(5)) = values(15)
                        dr(Row(6)) = values(16)

  开发者_JS百科                  End If

                    dt.Rows.Add(dr)

                End If
            Next

            If values(23) = "Error" Then
                invalidMessage()

            Else
                #Bind the DataTable to the DataGrid
                Table1.Visible = True
                Table1.DataSource = dt
                Table1.DataBind()
            End If
        End If
    Catch ex As Exception
        invalidMessage()
    Finally
        Array.Clear(records, 0, records.Length)
        Array.Clear(values, 0, values.Length)

    End Try

End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜